在“打开新窗口(window.open)"这一章节里,window.open括号内的”_blank“是用单引号括起来的,而在”编程练习“这一章节,必须使用双引号才能打开网址,这是为什么?请大神指教,谢谢~
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
function openWindow(){
var sel=confirm("是否要打开新网页?")
if(sel)
{
var sel2=prompt("请输入新网页的地址:","http://www.imooc.com");
if(sel2!=null){
window.open(sel2,'_blank','height=500px,width=400px','menubar=no,toolbar=no');
}
else
{
alert("byebye!");
}
}
else
{
alert("byebye");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>浏览器不支持= =。以求证用单引号可以解决问题。
1+1=2
没有吧,单引号可以打开的