Javascript 我如何调整此代码以在Google站点上工作?
我目前正在尝试开发一个随机重定向按钮,需要对以下代码进行两次调整:Javascript 我如何调整此代码以在Google站点上工作?,javascript,html,url,redirect,web,Javascript,Html,Url,Redirect,Web,我目前正在尝试开发一个随机重定向按钮,需要对以下代码进行两次调整: <script> <!-- /* Random link button- By JavaScript Kit (http://javascriptkit.com) Over 300+ free scripts! This credit MUST stay intact for use */ //specify random links below. You can have as many as you wa
<script>
<!--
/*
Random link button- By JavaScript Kit (http://javascriptkit.com)
Over 300+ free scripts!
This credit MUST stay intact for use
*/
//specify random links below. You can have as many as you want
var randomlinks=new Array()
randomlinks[0]="http://surveymonkey.com"
randomlinks[1]="http://typeform.com"
randomlinks[2]="http://dynamicdrive.com"
randomlinks[3]="http://cnn.com"
randomlinks[4]="http://www.geocities.com"
function randomlink(){
window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
}
//-->
</script>
<form method="post">
<p><input type="button" name="B1" value="Continue" onclick="randomlink()"></p> </form>
上面的代码生成一个按钮,在发布的网站上单击该按钮时,该按钮似乎不起任何作用。如何使按钮实际重定向?我还想调整按钮的大小,使其大5倍并对齐中心
感谢您的帮助。它无法打开的原因是函数中使用的
.open
方法
这是使用窗口的新代码。打开:
window.open(randomlinks[Math.floor(Math.random()*randomlinks.length)]);
设置按钮格式时,应使用CSS
查看类似于浏览器的javascript控制台中出现了什么错误?在这里它对我有效