专注Java教育14年 全国咨询/投诉热线:444-1124-454
星辉LOGO图
始于2009,口口相传的Java黄埔军校
首页 hot资讯 HTML页面跳转和传递参数

HTML页面跳转和传递参数

更新时间:2022-07-19 07:34:59 来源:星辉 浏览1675次

HTML教程中,大家会学到很多相关知识,星辉小编先来给大家说说HTML页面跳转和传递参数。

HTML页面跳转:

window.open(url, "", "width=600,height=400");

第二个参数:_self,在当前窗口中打开一个窗口;_blank(默认值),在另一个新窗口中打开一个新窗口;

Window.location.href= "https://www.jb51.net"; //Open a window in the same current window
Window. history. back (- 1); /// Return to the previous page
 <a href="http://www.baidu.net"  target="_blank">

HTML 参数传递:

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星辉在线学习,里面的课程内容从入门到精通,细致全面,很适合没有基础的小伙伴学习,希望对大家能够有所帮助哦。

提交申请后,顾问老师会电话与您沟通安排学习

免费课程推荐 >>
技术文档推荐 >>