[Switch] JS acquisition parameters passed by iframe url

1 Introduction

Get the iframe url path: window.parent.document.getElementById ( "your-iframe-id") contentWindow.location.search; // needs an iframe ID

2. Code

The value of the regularization parameter acquired by the parameter name

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 References

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

Guess you like

Origin www.cnblogs.com/fanbi/p/11670266.html