1. 程式人生 > 其它 >H50080:html url 地址獲取id 嵌入iframe並動態傳入id

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>
琥珀君的部落格