为什么str.replace有时候实现不了 你没注意alert出来的内容吗?在document.all.hello.innerHTML里放的并不是你写上去的HTML代码,是有经过IE自己整理过的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 superliufa(PXPE) 说得对,ie把内容重排了 我调试后也知道了,请再看下面的一段代码,原来图片的路径也自动变为绝对路径,真的是挺郁闷的,那位知不知道解决的办法啊<!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><script language="javascript">function check(){var str = document.all.hello.innerHTML;//var strs = str.valueOf();var str2 = 'ab<IMG height=12 src="2.gif" width=23>';if(str.indexOf('<IMG height=12 src="2.gif" width=23>')!==-1){var str5 = str.replace('<IMG height=12 src="2.gif" width=23>','');//alert(str5);document.all.hello.innerHTML = str5;var thestr = document.all.hello.innerHTML;alert(thestr);}//var str2 = str.replace('<img src="6.gif" width="23" height="12">','');//alert(str+'\n'+str2);//window.history.back();//document.all.hello.innerHTML = str2;//var str2 = 'ab<img src="6.gif" width="23" height="12">efg';//if(str == str2){//alert("sdfsdfsdf");//}else{//alert("12312312");//}//var str3 = str.replace(str2,'');}</script></head><body onLoad="check()"><div id="hello">ab<IMG height=12 src="1.gif" width=23><IMG height=12 src="2.gif" width=23>efg</div><div id="hello2"></div></body></html> 正则表达式解决<img> <IMG> 问题已经解决 下面是解决路径的代码<!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><script language="javascript">function show(){var strpath = hello.src;var thenum = strpath.lastIndexOf("/");var strpath2 = strpath.substr(thenum+1,10);var strpath3 = strpath.replace(strpath2,"");alert(strpath+'\n'+thenum+'\n'+strpath2+'\n'+strpath3);//var thestr = document.all.layer.innerHTML;//alert(thestr);}</script></head><body onLoad="show()"><div id="layer"><a href="sdfsdfsdf" class="link1" target="_blank"><img src="1.gif" width="23" height="12" id="hello"></a></div></body></html> 类似京东的框框查询,请问这是什么效果 Ext 文件上传用Ext.ux.UploadDialog问题 武汉亨通科技有限公司怎么样? 帮忙改个JS特效,主要是浏览器兼容问题! 双击frameset边框自动隐藏或显示窗口 java私塾是这样对我的,大家来认清他! javascript函数参数问题--急急急 100分求教:关于鼠标右键问题 sct的问题 在web页面上,如何动态限制用户可否在某些输入框输入内容.. 如何获取post过来的值 prototype.js的源文件中,经常出现iterator,我不太理解,请达人明示?
<!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>
<script language="javascript">
function check(){
var str = document.all.hello.innerHTML;
//var strs = str.valueOf();
var str2 = 'ab<IMG height=12 src="2.gif" width=23>';
if(str.indexOf('<IMG height=12 src="2.gif" width=23>')!==-1){
var str5 = str.replace('<IMG height=12 src="2.gif" width=23>','');
//alert(str5);
document.all.hello.innerHTML = str5;var thestr = document.all.hello.innerHTML;
alert(thestr);
}
//var str2 = str.replace('<img src="6.gif" width="23" height="12">','');
//alert(str+'\n'+str2);
//window.history.back();
//document.all.hello.innerHTML = str2;
//var str2 = 'ab<img src="6.gif" width="23" height="12">efg';
//if(str == str2){
//alert("sdfsdfsdf");
//}else{
//alert("12312312");
//}
//var str3 = str.replace(str2,'');
}
</script>
</head><body onLoad="check()">
<div id="hello">ab<IMG height=12 src="1.gif" width=23><IMG height=12 src="2.gif" width=23>efg</div>
<div id="hello2"></div>
</body>
</html>
<img> <IMG>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
function show(){
var strpath = hello.src;
var thenum = strpath.lastIndexOf("/");
var strpath2 = strpath.substr(thenum+1,10);
var strpath3 = strpath.replace(strpath2,"");
alert(strpath+'\n'+thenum+'\n'+strpath2+'\n'+strpath3);//var thestr = document.all.layer.innerHTML;
//alert(thestr);
}
</script>
</head><body onLoad="show()">
<div id="layer">
<a href="sdfsdfsdf" class="link1" target="_blank"><img src="1.gif" width="23" height="12" id="hello"></a>
</div>
</body>
</html>