Html 在iframe src URL中放入一个随机数
我想在Html 在iframe src URL中放入一个随机数,html,url,iframe,random,Html,Url,Iframe,Random,我想在?I= <li> <strong> Clip</strong> 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> Clip</strong> 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。