两者都是用git实现代码托管的版本仓库,两者很相似,那它们的区别是?
跳转页面
html加参数onclick=”function()”
function里写window.open("url", _self/__blank(default);
或者1
2window.location.href="url";
window.history.back(-1);
参数传递:
url传参:
第一个页面(a.html):1
2
3
4var obj = a.value; //传给弹出页面参数
var url = 'jxb.html?obj='+obj;
url = encodeURI(url);
window.open(url, "", "width=600,height=400");第二个页面(b.html):
1
2
3
4var url = decodeURI(window.location.href);
var argsIndex = url .split("?obj=");
var arg = argsIndex[1];注:中文传输:可以在页面a用encodeURI 编码url 在b页面用decodeURI解码url
cookie传参(不能跨域):
1
2
3
4
5
6
7function setCookie(cname,cvalue){
document.cookie = cname + "=" + cvalue;
}
function getCookie(cname){
var name = cname + "=";
var ca = document.cookie;
}`localStorage对象传参:
1
2
3
4
5
6
7a.html:
var div = doucment.getElementById('要获取字符串的DIV ID名');
localStorage.string = div.textContent;
b.html:
var div = doucment.getElementById('要写入的DIV ID名');
div.textContent = localStorage.string;window.opener()
父页面:1
2<input type="text" name="textfield" id="textfield"/>
window.open("子页面.html");子页面:
1
window.opener.document.getElementByIdx('textfield').value='123123123';
如果跨域,子页面还要加上document.domain=”父页面url”