1.不是必须
2.因为是字符串所以要用引号
用单引号或双引号都可以
3.这是个构造函数
建立对象就这样一种固定的方法,前提是已经定义了相应的类
new就是用来创建对象的
2.因为是字符串所以要用引号
用单引号或双引号都可以
3.这是个构造函数
建立对象就这样一种固定的方法,前提是已经定义了相应的类
new就是用来创建对象的
解决方案 »
- 小弟刚接触js,关于计时器的问题,现上代码,求解决。
- 求推荐一本Javascript教材
- jquery新手求助
- 很迷惘的一行js代码,难道div有src属性吗?
- 有什么工具可以在网页运行的时候修改JS代码的?
- offsetwidth 在ie和 firefox1.5下值不相同的问题
- 一个简单问题,如何获取当前窗口的高度?
- 如何得到窗口距屏幕左侧的距离???
- 哪位大哥帮忙一下!
- 我用<script src="tt.js">形式引用js文件,然后在页内用其中的function,为什么会找不到对象,细见内
- 如何安装WINDOWS SCRIPT HOST.
- 如何从一个子frame中修改另一个子frame的文本框的内容
比如,内容都是document.write出来的,不document.close,ie会一直显示下载,也就不会触发onload时间。
看不出错在哪里了?
<html>
<head>
<script>
function open_new_win()
{
var message = "the document writing output has been closed!"
var my_win = window.open("","","width=300,height=300")
my_win.document.writeln("<html>")
my_win.document.writeln("<head>")
my_win.document.writeln("</head>")
my_win.document.writeln('<body onLoad="alert(message)">')
my_win.document.writeln("this is a test to see whether the closure of the document is necessary!")
my_win.document.writeln("</body>")
my_win.document.writeln("</html>")
my_win.document.close()
}
</script>
</head>
<body>
<input type="button" value="test" onClick="open_new_win()">
</body>
</html>
<head>
<script>
function open_new_win()
{
var message = "the document writing output has been closed!"
var my_win = window.open("","","width=300,height=300")
my_win.document.writeln("<html>")
my_win.document.writeln("<head>")
my_win.document.writeln("</head>")
my_win.document.writeln('<scri'+'pt>alert("test");var message="the document writing output has been closed!";</scri'+'pt>')
my_win.document.writeln('<body onLoad="alert(message)">')
my_win.document.writeln("this is a test to see whether the closure of the document is necessary!")
my_win.document.writeln("</body>")
my_win.document.writeln("</html>")
my_win.document.close()
}
</script>
</head>
<body>
<input type="button" value="test" onClick="open_new_win()">
</body>
</html>
改为
my_win.document.writeln('<body onLoad="alert(\'message\')">')
原行在弹出窗口里写入<body onLoad="alert(message)"> 而message并未定义,出错了所以不弹出对话框