Safari Bug ?
Safari 浏览器下 select 不能window.open , button 却可以
为什么?怎么解决这个问题呢?
Safari bug 百度 HTML 浏览器
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<select id="sl">
<option value="1">百度1</option>
<option value="2">百度2</option>
<option value="3">百度3</option>
<option value="4">百度4</option>
<option value="5">百度5</option>
</select>
<input type="button" id="btn" value="跳转" />
<script type="text/javascript">
document.getElementById('sl').onchange = function () {
window.open('http://www.baidu.com')
};
document.getElementById('btn').onclick = function () {
window.open('http://www.baidu.com')
};
</script>
</body>
</html>
[解决办法]
把你form中的target属性拿掉也是没问题的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<form id="myform" method="get" action="http://www.baidu.com">
<select id="sl" onchange="fun1()">
<option value="1">百度1</option>
<option value="2">百度2</option>
<option value="3">百度3</option>
<option value="4">百度4</option>
<option value="5">百度5</option>
</select>
<input type="button" id="btn" value="跳转" />
</form>
<script type="text/javascript">
function fun1(){
document.getElementById('myform').submit();
}
document.getElementById('btn').onclick = function () {
window.open('http://www.baidu.com')
};
</script>
</body>
</html>
[解决办法]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style>
.select{
display:inline-block;
border: solid 1px blue;
width: 100px;
padding: 10px;
text-align: center;
}
.select>div{
}
.select>input{
display: none;
}
.select:hover>div{
display: none;
}
.select:hover>input{
display: block;
width: 100%;
margin-top: 5px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<div class="select">
<div>选择</div>
<input type="button" id="btn1" value="百度" />
<input type="button" id="btn2" value="百度" />
<input type="button" id="btn3" value="百度" />
<input type="button" id="btn4" value="百度" />
<input type="button" id="btn5" value="百度" />
<input type="button" id="btn6" value="百度" />
</div>
<script type="text/javascript">
for(var i = 1; i<=6;i++)
document.getElementById('btn' + i ).onclick = function () {
window.open('http://www.baidu.com');
};
</script>
</body>