zoukankan      html  css  js  c++  java
  • [转]js获取iframe通过url传递的参数

    1.前言

    获取iframe的url路径:window.parent.document.getElementById("your-iframe-id").contentWindow.location.search; //需要iframe的ID

    2.代码

    根据参数名称通过正则获取参数值

    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 "";
            }

    3 参考

    1.https://www.cnblogs.com/kcjm/p/7060073.html

  • 相关阅读:
    9.17 HTML CSS
    9.16
    9.15
    9.14
    9.13
    9.12
    9.11
    9.10
    9.9
    9.8
  • 原文地址:https://www.cnblogs.com/fanbi/p/11670266.html
Copyright © 2011-2022 走看看