js獲取iframe通過url傳遞的參數
阿新 • • 發佈:2017-06-21
ear 路徑 del bst func tel earch -i return
獲取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傳遞的參數