更新時間:2022-07-19 07:34:59 來源:動力節點 瀏覽2246次
在HTML教程中,大家會學到很多相關知識,動力節點小編先來給大家說說HTML頁面跳轉和傳遞參數。
window.open(url, "", "width=600,height=400");
第二個參數:_self,在當前窗口中打開一個窗口;_blank(默認值),在另一個新窗口中打開一個新窗口;
Window.location.; //Open a window in the same current window
Window. history. back (- 1); /// Return to the previous page
<a target="_blank">
1. 網址參考:
第一頁(a.html):
Var obj = a. value; // Pass to pop-up page parameters
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頁面編碼URL,在B頁面解碼U??RL。
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 = douction. getElementById ('The DVI ID name of the string to be obtained');
localStorage.string = div.textContent;
b.html:
Var div = douction. getElementById ('DVI ID name to write');
div.textContent = localStorage.string;
4.window.opener()
父頁面:
<input type="text" name="textfield" id="textfield"/>
Window.open ("sub-page.html");
子頁面:
window.opener.document.getElementByIdx('textfield').value='123123123';
以上就是小編介紹的HTML頁面跳轉和傳輸參數。如果大家想了解更相關知識,不妨來關注一下動力節點的Java在線學習,里面的課程內容從入門到精通,細致全面,很適合沒有基礎的小伙伴學習,希望對大家能夠有所幫助哦。
0基礎 0學費 15天面授
有基礎 直達就業
業余時間 高薪轉行
工作1~3年,加薪神器
工作3~5年,晉升架構
提交申請后,顧問老師會電話與您溝通安排學習