H50080:html url 地址获取id 嵌入iframe并动态传入id

1,访问地址:

https://www.xxx.com/xxx.html?id=bmRMH3GfST

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>空间</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        iframe {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            height: 100%;
            width: 100%;
        }
    </style>

<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?4447de3b4a47f73e510bb33a690706eb";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
// 获取url参数名
function GetQueryString(name)
{
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null){
        return unescape(r[2]);
 
    }else{
        return null;
    }
}
function cc(){
    document.getElementById('frameid').src="https://www.xxx/ys/player.html?id="+GetQueryString('id');
}

</script>

</head>


<body onload="cc()">
<iframe name="son" id="frameid" src="" width="100%" height="100%" scrolling="no" frameborder="no"  security="restricted" sandbox="allow-top-navigation allow-same-origin allow-forms allow-scripts">
</iframe>

</body>
</html>
琥珀君的博客
原文地址:https://www.cnblogs.com/eliteboy/p/15415404.html