【发布时间】:2012-03-23 23:49:49
【问题描述】:
这是一个选择州的简单脚本,然后根据所选州选择一个地区,然后单击转到该网站
它在 IE 中完美运行。
代码在http://goldcoast.info/Chat.php
我已经尝试了很多方法来尝试让它在 Firefox 中运行,症状是当您单击按钮时它不会转到所选的网站。
如何在 Firefox 中使用它?
<script language='JavaScript'>
function setOptions(chosen) {
var selbox = document.myform.opttwo;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please Select State',' ');
}
if (chosen == "NSW") {
selbox.options[selbox.options.length] = new Option('Blue Mountains','bluemountains.info');
selbox.options[selbox.options.length] = new Option('Coffs Coast','coffscoast.info');
}
if (chosen == "QLD") {
selbox.options[selbox.options.length] = new Option('Cairns','cairns.info');
selbox.options[selbox.options.length] = new Option('The Gold Coast','goldcoast.info');
}
if (chosen == "VIC") {
selbox.options[selbox.options.length] = new Option('Geelong','geelong.info');
selbox.options[selbox.options.length] = new Option('Phillip Island','phillipisland.info');
}
}
</script>
<form name="myform"><div class="centre">
State<br>
<select name="optone" size="1"
onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected"> </option>
<option value="NSW">New South Wales</option>
<option value="QLD">Queensland</option>
<option value="VIC">Victoria</option>
</select><br>Region<br>
<select name="opttwo" size="1">
<option value=" " selected="selected">Please Select State</option>
</select><br />
<input class="red" type="button" name="go" value="Go There"
onclick="window.location.href('http://' + document.myform.opttwo.options[document.myform.opttwo.selectedIndex].value + '/index.php');return false">
</div></form>
【问题讨论】:
-
您必须提供比“在 Firefox 中失败”更多的细节。
-
当您在 Firefox 中单击 [Go There] 按钮时,它什么也不做,在 IE 中它会转到网站
标签: javascript html forms firefox