代码如下:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<img name= "img1" id= "img1" src="javascript:showpic();">
</body>
</html><script>
function showpic()
{
// 此处"holiday.png"本来是变量值,为了调试方便,设为固定值测试
document.getElementById("img1").src = "holiday.png";
}
</script>在IE中图片能够正常显示,而在火狐浏览器、谷歌浏览器中图片不显示。请大家帮忙看看!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<img name= "img1" id= "img1" src="javascript:showpic();">
</body>
</html><script>
function showpic()
{
// 此处"holiday.png"本来是变量值,为了调试方便,设为固定值测试
document.getElementById("img1").src = "holiday.png";
}
</script>在IE中图片能够正常显示,而在火狐浏览器、谷歌浏览器中图片不显示。请大家帮忙看看!
没用过这个用法
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<img name= "img1" id= "img1" src="">
</body>
</html><script>
function showpic()
{
document.getElementById("img1").src = "holiday.png";
} window.onload=showpic;
</script>这样可以
<img name= "img1" id= "img1" src="javascript:showpic();">
</body>src改成onload