0%
iframe 标签与父页面的传值
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
function toChildDefaultMd(){ var md = "../md/test.md"; return md; }
function toChildSelectMd(str){ if(str == null){ str = "../md/test.md"; } var ifra = document.getElementById("iframe"); ifra.contentWindow.showMarkdown(str); }
var md = window.parent.toChildDefaultMd(); showMarkdown(md)
function showMarkdown(str) {}
function toChildValue() { var txt = wH; return txt; }
var getParentVule = window.parent.toChildValue();
var main = document.getElementById('main'); main.style.height = getParentVule + 'px';
|
页面跳转,获取参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <a href="index.html?arr=哼">测试</a>
var url = location.search; var theRequest = new Object(); var arr; var sp = ""; if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]); } var Request = new Object(); Request = theRequest;
arr = Request['arr']; }
|
元素居中
1 2 3 4 5 6 7 8 9 10 11
| // 水平居中 left: 50%; margin-left: -15px; // 宽度的一半,并且为负数 position: absolute;
// 元素居中 position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
|
js 动态创建布局
1 2 3 4 5 6 7 8 9 10 11 12
| var index_content = document.getElementById("index_content");
var arrValue = ""; var lim = ""; var arrLength=""; for (var i = 0; i < arrLength; i++) { var li = "<div><a href='content.html?arr=" +i +","+ arrValue + "'target='_self'>" + arrValue + "</a></div>"; } lim += li; } index_content.innerHTML = lim;
|
传参乱码
1 2 3 4 5 6 7 8 9 10 11 12
|
<div onclick="toHref('index.html?arr=1')">点击</div> function toHref(url){ var searchUrl=encodeURI(url); console.log(searchUrl); window.location.href = searchUrl; }
var url = decodeURI(window.location.href.split('?')[1]);
|