Rid*_*ari 2 html javascript internet-explorer-6
因此,我使用带有国家/地区列表的HTML选择框和一个按钮,打开一个小窗口,其中包含HTML选择框中所选项目的更多详细信息.
这是我如何做到这一点(我在这里预先为任何noobishness道歉,我仍然是Javascript的新手):
//in header
<script type="text/javascript">
function popUp()
{
countryName = document.getElementById("countrylist").value;
document.write(countryName);
dest = "countries/" + countryName + ".html";
window.open(dest, 0, "toolbar=0, scrollbars=0, statusbar=0, menubar=0,resizable=0,width=400,height=400,left=440,top=312");
}
</script>
<form id="countryform">
<select id="countrylist">
<!--List of countries removed for brevity-->
</select>
<input type="button" name="countryBtn" value="Submit Query" onClick="popUp();">
</form>
Run Code Online (Sandbox Code Playgroud)
这在Firefox中运行良好,但在IE6中不行.任何帮助,将不胜感激!
更新:所以我尝试了下面的前两种方法,替代弹出功能在任一浏览器中都不起作用,并且替换document.getElementById行没有改变任何东西,在Firefox中仍然可以正常工作,不在IE中.
document.getElementById("countrylist").value;
Run Code Online (Sandbox Code Playgroud)
需要是:
document.getElementById("countrylist")[document.getElementById("countrylist").selectedIndex].value;
Run Code Online (Sandbox Code Playgroud)