Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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
Javascript 我如何调整此代码以在Google站点上工作?_Javascript_Html_Url_Redirect_Web - Fatal编程技术网

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控制台中出现了什么错误?在这里它对我有效