js获取iframe通过url传递的参数
Posted 小小程序员
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js获取iframe通过url传递的参数相关的知识,希望对你有一定的参考价值。
获取iframe的url路径:window.parent.document.getElementById("Ateon-SetParent-iframe").contentWindow.location.search //需要iframe的ID
根据参数名称通过正则获取参数值
function geturl (name) {
var reg = new RegExp("[^\?&]?" + encodeURI(name) + "=[^&]+");
var arr = window.parent.document.getElementById("Ateon-SetParent-iframe").contentWindow.location.search.match(reg);
if (arr != null) {
return decodeURI(arr[0].substring(arr[0].search("=") + 1));
}
return "";
}
以上是关于js获取iframe通过url传递的参数的主要内容,如果未能解决你的问题,请参考以下文章