0
因此,我创建了一个无用的网站,我需要制作一个按钮,将用户指向新标签中的随机网站。我已经有了随机链接按钮代码,但我似乎不能用新的标签代码添加它。如何在新标签页中随机链接中打开HTML按钮
样品
var randomlinks=new Array(10)
randomlinks[0]="http://ducksarethebest.com/"
randomlinks[1]="http://cant-not-tweet-this.com/"
randomlinks[2]="http://just-shower-thoughts.tumblr.com/"
randomlinks[3]="http://www.fallingfalling.com/"
randomlinks[4]="http://www.partridgegetslucky.com/"
randomlinks[5]="http://ducksarethebest.com/"
randomlinks[6]="http://cant-not-tweet-this.com/"
randomlinks[7]="http://just-shower-thoughts.tumblr.com/"
randomlinks[8]="http://www.fallingfalling.com/"
randomlinks[9]="http://www.staggeringbeauty.com/"
randomlinks[10]="http://www.trypap.com/"
function randomlink(){
window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
}
的Html
<form method="post">
<p><input type="button" name="B1" value="Random Link >>" onclick="randomlink()""window.open'"></p>
</form>
or
<a href="javascript:randomlink()">Random Link</a>
所以,你能告诉我完整的代码我应该使用和添加。 –
@IshraqKhan更新。 – SEUH