<html>
<head>
<title>打开新页面</title>
<script type="text/javascript">
function showpicture(){
var newWindow=window.open("","所有链接","height=1000,widht=1100,resizable=no");
var a=Array(3);
for(var j=0;j<document.images.length;j++){
newWindow.document.writeln(document.images[j].images);
newWindow.document.writeln("<br>");
}
}
</script>
</head>
<body>
<img id="testImg" src="1.jpg" width=200 height=250>
<img id="testImg" src="2.jpg" width=200 height=250>
<img id="testImg" src="3.jpg" width=200 height=250>
<br>
<input type="button" value="显示所有图片"
onclick="showpicture();"><br>
</body>
</html>
要求是打开新窗口中的所有图片。
请指出以上代码中的错误?
<head>
<title>打开新页面</title>
<script type="text/javascript">
function showpicture(){
var newWindow=window.open("","所有链接","height=1000,widht=1100,resizable=no");
var a=Array(3);
for(var j=0;j<document.images.length;j++){
newWindow.document.writeln(document.images[j].images);
newWindow.document.writeln("<br>");
}
}
</script>
</head>
<body>
<img id="testImg" src="1.jpg" width=200 height=250>
<img id="testImg" src="2.jpg" width=200 height=250>
<img id="testImg" src="3.jpg" width=200 height=250>
<br>
<input type="button" value="显示所有图片"
onclick="showpicture();"><br>
</body>
</html>
要求是打开新窗口中的所有图片。
请指出以上代码中的错误?
function showpicture(){
var images = document.getElementsByTagName("image");
var newWindow=window.open("","所有链接","height=1000,widht=1100,resizable=no");
var a=Array(3);
for(var j=0;j<document.images.length;j++){
newWindow.document.writeln(images[j].outerHTML);
newWindow.document.writeln("<br>");
}
}
应该改成newWindow.document.writeln(document.images[j].outerHTML);
这样才是我的效果! 多谢指教!