<script>
var picpath_true=new Array('asd&e2',"&","sy&wq")var temp_entity = '';
for(var i=0; i<picpath_true.length; i++) {
temp_entity = picpath_true[i].replace(/&/g, '&');
alert(picpath_true[i]+'\n'+temp_entity);
}
</script>
其他的问题吧,
我测试没问题呀
var picpath_true=new Array('asd&e2',"&","sy&wq")var temp_entity = '';
for(var i=0; i<picpath_true.length; i++) {
temp_entity = picpath_true[i].replace(/&/g, '&');
alert(picpath_true[i]+'\n'+temp_entity);
}
</script>
其他的问题吧,
我测试没问题呀
你alert(picpath_true[i])试试
var pattern = /&/g
var str="a&b&cad&asi";
var str2;
function test() {
str2=str.replace(pattern,"&");
alert(str2);
}
</script>
可以
奇怪了,你试着像我这样先定义个正则看看
的值是什么,包含&吗?
'{A_PIC_SHOW}perfee=0&kind=picture&img_id=b05111003&CPID=80007'
'{A_PIC_SHOW}perfee=0&kind=picture&img_id=b05111004&CPID=80007'
'{A_PIC_SHOW}perfee=0&kind=picture&img_id=b05111005&CPID=80007'
我就纳闷了,你不是显示了替换前与替换后的值了吗?
一看不就清楚是replace函数没起作用还是没取到值?
另外偿试下其它形式的写法,或者换个环境测试
var picpath_true=new Array('{A_PIC_SHOW}perfee=0&kind=picture&img_id=b05111003&CPID=80007','{A_PIC_SHOW}perfee=0&kind=picture&img_id=b05111004&CPID=80007','{A_PIC_SHOW}perfee=0&kind=picture&img_id=b05111005&CPID=80007')var temp_entity = '';
for(var i=0; i<picpath_true.length; i++) {
temp_entity = picpath_true[i].replace(/&/g, '&');
alert(picpath_true[i]+'\n'+temp_entity);
}
</script>
没问题呀,??
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var picpath_true=new Array('asd&e2',"&","sy&wq")
var temp_entity = '';
for(var i=0; i<picpath_true.length; i++) {
temp_entity = picpath_true[i].replace(/&/g, '&');
alert(picpath_true[i]+'\n'+temp_entity);
}
//-->
</SCRIPT>
</BODY>
</HTML>没问题。还有其他信息提供吗?
var picpath_true = new Array();
var picpath_prvw = new Array();
var temp_html = '';
var temp_entity = '';
var i = 0;
</script>
<td><input type="button" value="预览" onclick="if(this.value=='预览') { document.getElementById('preview').style.display='block'; document.getElementById('preview').innerHTML=frames['editor'].document.body.innerHTML.replace(/{APP_WAP_HOST}wap_show/g, '../show_prvw'); for(var i=0; i<picpath_true.length; i++) { temp_entity=picpath_true[i].replace(/&/g, '&'); temp_html=document.getElementById('preview').innerHTML.replace(temp_entity, picpath_prvw[i]); } document.getElementById('preview').innerHTML=temp_html; this.blur(); document.getElementById('x_o').style.display='none'; hide_btn(); this.value='编辑'; } else { document.getElementById('preview').style.display='none'; display_btn(); document.getElementById('x_o').style.display='block'; this.value='预览'; }" /></td>
在a_child.html中(a_child.html与main_editor.html的关系是:mail_editor.html中弹出一个窗口a_parent.html,a_child.html是a_parent.html中的一个iframe):<dt title="点击添加" style="background: url('<{$aPics[pics].pic_path}>') no-repeat center; height: 128px;" onclick="var picpath='{A_PIC_SHOW}perfee='+document.getElementById('perfee').value+'&kind=<{$aPics[pics].kind}>&img_id=<{$aPics[pics].pic_code}>&CPID=<{$CPID}>'; handler.format('CreateLink', picpath); handler.picpath_true[handler.i]=picpath; handler.picpath_prvw[handler.i]='<{$aPics[pics].pic_path}>'; handler.i++; parent.close();"></dt>
<script>
var handler = parent.window.opener;
</script>
alert出的内容说明picpath_true数组接收到了值
建议你把它写成的函数的形式。
这些代码别人也不能调试。
但是可以肯定的说你的替换的代码没有问题。