求“点击一个按钮,随机打开0-10html中一个网页,要新窗口打开”代码
<body><divclass="a"><divclass="ab"><scriptlanguage="javascript">functiontest(){varurl...
<body>
<div class="a">
<div class="ab">
<script language="javascript">
function test(){
var url=new Array();
url[0]="2.html";
url[1]="3.html";
url[2]="4.html";
url[3]="5.html";
var ints=parseInt(Math.random()*(url.length));
window.open(url[ints]);//本窗口打开
window.location=url[ints];//新窗口打开
}
</script>
<div class="abd"><a href="javascript:test()" //onclick="this.href=parseInt(Math.random()*5+1)+'.html'"//><button onclick="demo"><img src="images/3145_Hextech_Revolver.png" width="64" height="64" /></button>
</a></div>
</div>
</div>
</body>
这段代码只能在原来窗口打开,不能新窗口打开 展开
<div class="a">
<div class="ab">
<script language="javascript">
function test(){
var url=new Array();
url[0]="2.html";
url[1]="3.html";
url[2]="4.html";
url[3]="5.html";
var ints=parseInt(Math.random()*(url.length));
window.open(url[ints]);//本窗口打开
window.location=url[ints];//新窗口打开
}
</script>
<div class="abd"><a href="javascript:test()" //onclick="this.href=parseInt(Math.random()*5+1)+'.html'"//><button onclick="demo"><img src="images/3145_Hextech_Revolver.png" width="64" height="64" /></button>
</a></div>
</div>
</div>
</body>
这段代码只能在原来窗口打开,不能新窗口打开 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询