Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在iframe src URL中放入一个随机数_Html_Url_Iframe_Random - Fatal编程技术网

Html 在iframe src URL中放入一个随机数

Html 在iframe src URL中放入一个随机数,html,url,iframe,random,Html,Url,Iframe,Random,我想在?I= <li> <strong>&nbsp; &nbsp;Clip</strong>&nbsp;2<br> <iframe src="https://mysite.ml/links/clip2.html?i=" height="350" width="600" frameborder="0" scrolling="no" allowfullscreen="true"></iframe>

我想在
?I=

<li>
  <strong>&nbsp; &nbsp;Clip</strong>&nbsp;2<br>
  <iframe src="https://mysite.ml/links/clip2.html?i=" height="350" width="600" frameborder="0" scrolling="no" allowfullscreen="true"></iframe>
</li>
  • 剪辑2

  • 首先,确保您的
    iframe
    具有
    id
    属性,例如:

    
    
    然后
    onpageload
    ,使用JavaScript设置附加了
    Math.random()
    src
    属性,例如:

    document.getElementById(“myrandomiframe”).setAttribute(“src”),“https://mysite.ml/links/clip2.html?i=“+Math.random());
    
    当页面加载JavaScript时,您必须这样做

    window.addEventListener('load',function(){
    document.getElementsByTagName(“iframe”)[0].src+=rando(Number.MAX\u SAFE\u INTEGER);
    log(document.getElementsByTagName(“iframe”)[0].src);
    });
    
    
    
    您是否尝试自己解决此问题?如果是的话,你能给我们看一下代码吗?如果没有,请尝试一下并更新您的问题/创建一个新问题。尝试使用javascript动态设置带有url和随机数的src。