首页 课程 师资 教程 报名

HTML页面跳转和传递参数

  • 2022-07-19 07:34:59
  • 1703次 星辉

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

选你想看

你适合学Java吗?4大专业测评方法

代码逻辑 吸收能力 技术学习能力 综合素质

先测评确定适合在学习

在线申请免费测试名额
价值1998元实验班免费学
姓名
手机
提交