最赞回答 / lprainbow
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" Content="text/html; charset=utf-8" /><title>javascript</title><style type="text/css">body{font-size:12px;} #txt{ height:400px; width:600p...
2016-01-26
function openWindow()
{ var a=confirm("确定打开?");
if(a==true){
var b=prompt("输入网址","http://www.imooc.co")
if(b=="http://www.imooc.co")
{window.open('http://www.imooc.com','_blank','width=400,height=500,menubar=no,toolar=no');
}
}
}
{ var a=confirm("确定打开?");
if(a==true){
var b=prompt("输入网址","http://www.imooc.co")
if(b=="http://www.imooc.co")
{window.open('http://www.imooc.com','_blank','width=400,height=500,menubar=no,toolar=no');
}
}
}
function openWindow(){
var open=confirm("open/No");
if(open){
var httpWindow=prompt("please input http:", "http://www.imooc.com");
if(httpWindow){
window.open(httpWindow,"_blank","width=400px,height=500px,menubar=no,tolbar=no");
}
}
}
var open=confirm("open/No");
if(open){
var httpWindow=prompt("please input http:", "http://www.imooc.com");
if(httpWindow){
window.open(httpWindow,"_blank","width=400px,height=500px,menubar=no,tolbar=no");
}
}
}
不明白的同学看这里:
输出null是因为页面还没加载,就想去获取id了,但那个时候id是不存在的.解决方法有1:把script放在id定义的后面,
2.在函数外面再套一个函数:window.onload=function (){}
输出null是因为页面还没加载,就想去获取id了,但那个时候id是不存在的.解决方法有1:把script放在id定义的后面,
2.在函数外面再套一个函数:window.onload=function (){}
2016-01-26
/**/实在是蛋疼啊.我打注释一半都是ctrl+/.如果是VS的话就是ctrl+k+c(还是u来着,反正一个是注释一个是取消).他怎么打就怎么打,我才不会刻意去/**/.如果是一行的直接手动//,/**/这个太少用到了
2016-01-26
最赞回答 / anzhaojun
是的,不需要。字符串要加双引号。比如var score=90;document("成绩为:"+score);加双引号为字符串内容,在网页的内容是: 成绩为:90
2016-01-26