window.open(url, , width=600,height=400);
第二個參數:_self,在目前視窗開啟視窗;_blank(預設值),在另外的新視窗開啟新視窗;
window.location.href=http://www.vevb.com; //在同目前視窗中開啟視窗window.history.back(-1); //回到上一頁<a href=http://www .baidu.net target=_blank>HTML參數傳遞: 1. url傳參:
第一個頁面(a.html):
var obj = a.value; //傳給彈出頁面參數var url = 'jxb.html?obj='+obj;url = encodeURI(url);window.open(url, , width=600,height=400) ;
第二頁(b.html):
var url = decodeURI(window.location.href);var argsIndex = url .split(?obj=);var arg = argsIndex[1];
註:中文傳輸:可以在頁面a用encodeURI 編碼url 在b頁面用decodeURI解碼url
2. cookie傳參:function setCookie(cname,cvalue){ document.cookie = cname + = + cvalue;}function getCookie(cname){ var name = cname + =; var ca = document.cookie;}3. localStorage物件傳參:
a.html:
var div = doucment.getElementById('要取得字串的DIV ID名');localStorage.string = div.textContent;
b.html:
var div = doucment.getElementById('要寫入的DIV ID名');div.textContent = localStorage.string;4. window.opener()
父頁面:
<input type=text name=textfield id=textfield/>
window.open(子頁面.html);
子頁面:
window.opener.document.getElementByIdx('textfield').value='123123123';總結
以上所述是小編給大家介紹的HTML頁面跳轉及傳遞參數問題,希望對大家有幫助,如果大家有任何疑問請給我留言,小編會及時回覆大家的。在此也非常感謝大家對VeVb武林網站的支持!