如何使用javascript Randomizer脚本链接到iframe,以便我可以从脚本中的链接列表中打开
How to use a javascript Randomizer script to link into an iframe so that i can open from a list of links in the script
如何从javascript随机化器中的随机url列表更改iframe的源。我很想使用js或html或css
下面的源代码是我当前网站的,它将你从列表中链接到一个随机网站,我想将它链接到的链接保存在一个页面中,该页面的格式与带有后退按钮等的框相同。
我的网站:http://www.boredombutton.co.uk
下面是我的代码的一部分:
<script type="text/javascript">
var url=[
'http://www.fallingfalling.com',
'http://www.omfgdogs.com',
];
window.onload=function()
{document.getElementById('trig').onclick=function(){
location.href=url[Math.floor(Math.random()*url.length)];}}
</script>
我想做的是iframe,在同一个iframe中选择的url可以互换。
我的网站的全部源代码如下:
<html>
<head>
<title>BoredomButton</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<script type="text/javascript">
var url=[
'http://www.fallingfalling.com',
'http://www.omfgdogs.com',
'http://www.republiquedesmangues.fr',
'http://www.staggeringbeauty.com',
'http://ducksarethebest.com',
'http://eelslap.com',
'http://heeeeeeeey.com',
'http://breakglasstosoundalarm.com'
];
window.onload=function()
{document.getElementById('trig').onclick=function(){
location.href=url[Math.floor(Math.random()*url.length)];}}
</script>
<body align="center" bgcolor="#egegeg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table align="center" id="Table_01" width="968" height="650" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3">
<img src="images/BoredomButton_01.png" width="968" height="363" alt=""></td>
</tr>
<tr>
<td rowspan="2">
<img src="images/BoredomButton_02.png" width="347" height="287" alt=""></td>
<td>
<a href="#" id="trig"><img src="images/BoredomButton_03.png" width="274" height="99" alt=""></td>
<td rowspan="2">
<img src="images/BoredomButton_04.png" width="347" height="287" alt=""></td>
</tr>
<tr>
<td>
<img src="images/BoredomButton_05.png" width="274" height="188" alt=""></td>
</tr>
</table>
</body>
</html>
感谢您提前提供的帮助,这将真正帮助
如果我理解正确,你想在iframe中加载URL,和会在网站上的某个地方显示所选的URL。
将您的功能更改为:
<script type="text/javascript">
var url=[
'http://www.fallingfalling.com',
'http://www.omfgdogs.com',
];
window.onload=function() {
var theURL = url[Math.floor(Math.random()*url.length)];
document.getElementById('trig').onclick=function() {
location.href=theURL;
}}
document.getElementById('chosenURL').innerHTML = '<a href="'+theURL+'">'+theURL+'</a>';
</script>
然后将这个HTML添加到你的页面中,在那里你想要文本:
<div id="chosenURL"></div>
相关文章:
- 我发现了一些只在移动设备上可见的垃圾邮件链接,我可以'找不到包含此垃圾邮件链接的脚本的位置
- 什么's使用链接和脚本标记引用JavaScript源之间的区别
- Javascript:在新页面中打开链接并运行脚本
- 如何通过分配单个变量来减少此脚本中的链接数
- jQuery Pan & Zoom 或 Magnify 脚本,具有热点或图像映射链接的能力
- 是否有脚本/代码可以一次将链接属性添加到多个链接
- 阅读第'页;s从chrome扩展中链接的脚本
- 脚本链接格式以实现跨浏览器兼容性
- 用于浏览器检测和url链接的脚本
- Javascript一页滚动脚本滚动到每个点击的链接一个接一个
- 多个脚本导致链接问题?Javascript、CSS、HTML、Jquery
- 在grumjs-minify/uglify之后更改html中的链接或脚本文件名
- 随机引用超链接脚本
- xdomain.js跨域链接脚本的jQuery indexOf错误
- 没有链接脚本或样式表的HTML
- 独立的web应用链接脚本-阻止它附加具有特定类的链接
- 有没有办法知道链接/脚本是否仍然挂起或失败
- facebook共享链接脚本
- 让Javascript在新窗口中省略外部链接脚本的锚标记
- 试图添加更多的jQuery到我的页面,但当我添加更多的链接/脚本标签,以前的功能jQuery停止运行.有人能帮帮我吗?