图片设置src之前如何不显示x

cloudgamer 2009-12-04 11:23:45
ie7中图片设置src之前如何不显示x

以前这样设置好像可以的
img.src = "javascript:void(0);";
但在ietest测试还是显示x
还有什么方法呢
...全文
507 41 打赏 收藏 转发到动态 举报
写回复
用AI写文章
41 条回复
切换为时间正序
请发表友善的回复…
发表回复
cloudgamer 2009-12-14
  • 打赏
  • 举报
回复
[Quote=引用 37 楼 dh20156 的回复:]
一定要用IMG来做滤镜容器么?DIV也可以吧? ^_^
[/Quote]

可以啊
只是用img就更好
了無痕 2009-12-14
  • 打赏
  • 举报
回复
alt=""
就好了
浴火_凤凰 2009-12-14
  • 打赏
  • 举报
回复
初始化加载一张图片,然后使用滤镜(比如设置透明度)使其隐藏,不知是否可行?
dh20156 2009-12-14
  • 打赏
  • 举报
回复
一定要用IMG来做滤镜容器么?DIV也可以吧? ^_^
wcwtitxu 2009-12-14
  • 打赏
  • 举报
回复
<img id="img" src="abc.gif" style="width:100px; height:100px; border:1px solid #000;"/>
<script type='text/javascript' src="img.js" language="javascript"></script>



img.js

/* <---------------------------- 这里必须 js 文件的首行
Content-Type: multipart/related; boundary="_cn_ialvin_web_script_javascript_"

--_cn_ialvin_web_script_javascript_
Content-Location:blankImage
Content-Transfer-Encoding:base64

R0lGODlhAQABAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw==
*/

function map(path) {
if (/^http\:\/{2}/i.test(path)) return path;
return "http://" + location.host
+ ((/^[\/]/.test(path))? "" : location.pathname.replace(/[^\/]*$/,'')) + path;
}

var currentScript = document.scripts[document.scripts.length-1];
!function() {
var img = document.getElementById("img");
if (/\bmsie [67]/i.test(window.navigator.userAgent)) {
img.src = ("mhtml:" + map(currentScript.src) + "!blankImage");
} else {
img.src = "data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw==";
}
}();
Web_Team 2009-12-13
  • 打赏
  • 举报
回复
我的想法是先不要给<img>指定SRC,这样<img>标签代表的就是一个图片占位符,是没有差号的,当要设置SRC时就用JS动态设置!
astrofay 2009-12-13
  • 打赏
  • 举报
回复
顶下
cloudgamer 2009-12-13
  • 打赏
  • 举报
回复
[Quote=引用 34 楼 web_team 的回复:]
我的想法是先不要给 <img>指定SRC,这样 <img>标签代表的就是一个图片占位符,是没有差号的,当要设置SRC时就用JS动态设置!
[/Quote]
是没有x但还是有一个小图标
cloudgamer 2009-12-11
  • 打赏
  • 举报
回复
[Quote=引用 32 楼 wcwtitxu 的回复:]
HTML code<imgwidth="100" height="100" border="1" src="data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw=="/>

IE6, IE7 不支持
[/Quote]

这个方法我也知道
所以我 问ie7
wcwtitxu 2009-12-11
  • 打赏
  • 举报
回复
<img width="100" height="100" border="1" src="data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw==" />


IE6, IE7 不支持
cloudgamer 2009-12-11
  • 打赏
  • 举报
回复
我要用img做容器显示滤镜
所以要显示img
yixianggao 2009-12-11
  • 打赏
  • 举报
回复
[Quote=引用楼主 cloudgamer 的回复:]
ie7中图片设置src之前如何不显示x

以前这样设置好像可以的
img.src = "javascript:void(0);";
但在ietest测试还是显示x
还有什么方法呢
[/Quote]

[Quote=引用 28 楼 cloudgamer 的回复:]
不是呢
我不要隐藏
因为我就是要显示它
[/Quote]
兄弟,你说“ie7中图片设置src之前如何不显示x”,可以你又说“我不要隐藏,因为我就是要显示它”?!

既然没有设置 src,你又要显示?!

你到底想达到啥效果呀?!

折腾半天都不知道你到底想要啥,详细说说先
chollaflower 2009-12-11
  • 打赏
  • 举报
回复
在加载图片前动态的将<img>标签创建出来,再添加相应的属性,也就是说在创建<img>标签时设置src属性,这样就相当于动态的显示了图片,需要时创建,不需要不创建,需要占位的话可以用<div>节点,把<img>节点动态的添加进去就行了!
cloudgamer 2009-12-11
  • 打赏
  • 举报
回复
不是呢
我不要隐藏
因为我就是要显示它
yixianggao 2009-12-11
  • 打赏
  • 举报
回复
兄弟要的是 #26 的效果么?

反正 IE 7 下没 X,能占位,
不过 FF 下没占位,前后的字直接连起来了!
yixianggao 2009-12-11
  • 打赏
  • 举报
回复
display 不好使,那是渲染,占位但不可见的话就用 visibility 控制!

L@_@K

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head>

<body>
图前边<img id="imgTest" width="200" height="100" alt="" />图后边
<script type="text/javascript">
<!--
var img = document.getElementById("imgTest");
img.style.visibility = "hidden";
img.onload = function() {
// Insert your code.
this.style.visibility = "visible";
// Insert your code.
};
// Change your image url.
img.src = "fontBoldSample.jpg";
//-->
</script>
</body>
</html>
cloudgamer 2009-12-11
  • 打赏
  • 举报
回复
估计没办法
还是再顶一下
ITDC_YiWang 2009-12-10
  • 打赏
  • 举报
回复
顶下
dudp1985 2009-12-10
  • 打赏
  • 举报
回复
visible:hidden
cloudgamer 2009-12-10
  • 打赏
  • 举报
回复
??
加载更多回复(21)

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧