标题:img内容是否存在求教
只看楼主
roy_guo
Rank: 1
等 级:新手上路
帖 子:107
专家分:0
注 册:2006-4-27
 问题点数:0 回复次数:0 
img内容是否存在求教

<html>
<head>
<script>
function op()
{
var img = document.getElementById("pic");
if (!img) {
img = document.createElement("img");
img.src = "123.jpg";
if(img.src != null)
{

}
else
{
img.style.position = "absolute";
img.style.left = "100px";
img.style.top = "100px";
img.style.zIndex = 0;
img.setAttribute("id", "pic");
img.src = "234.jpg";
p.appendChild(img);
}

}
}
</script>
</head>
<body onLoad="op()">
<div id="p"></div>

</body>
</html>
请问怎样使这段js代码在123.jpg不存在的情况下转而加载234.jpg?

2007-05-05 18:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-137097-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.791942 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved