【发布时间】:2019-09-26 14:52:55
【问题描述】:
我想要实现的是选择一个随机 URL,然后该 URL 的页面显示在嵌入中,然后您可以单击并转到该页面。但是,我遇到了麻烦,希望能提供任何帮助。这是我到目前为止得到的:
<script type="text/javascript">
var urls = new Array();
urls[0] = "https://www.google.com";
urls[1] = "https://www.yahoo.com";
urls[2] = "https://www.bing.com";
var random = Math.floor(Math.random()*urls.length);
window.location = urls[random];
<embed src="urls" style="width:500px; height: 300px;">
</script>
【问题讨论】:
-
<embed>标签不能放在<script>标签内。然后你应该设置 embed 标签的 src 属性,而不是 window.location;这就是页面本身。
标签: javascript html