<div id="wc">D:\wwwnew\WebApplication1\1.gif</div>
<script type="text/javascript" defer="defer">
var wc = document.getElementById("wc");
//替换后字符串"D:\\wwwnew\\WebApplication1\\1.gif"
alert(wc.innerHTML.replace(/\\/g, "\\\\"));
</script>
<script type="text/javascript" defer="defer">
var wc = document.getElementById("wc");
//替换后字符串"D:\\wwwnew\\WebApplication1\\1.gif"
alert(wc.innerHTML.replace(/\\/g, "\\\\"));
</script>
解决方案 »
- 通过JS填充DOM元素再实例化的iScroll对象不能正常运行,求救.
- js 读取 EXCEL文件数据中的Range对象问题?
- 求助文件路径问题
- 输入框自动跳转及自动粘贴
- ajax中取对象ID的问题
- 问源码: 实现数据结构 PriorityQueue, Doubly Linked List, Map, Ordered Binary Tree, Set 的基本实现
- ckeditor问题
- 请高手帮忙看下这段代码
- 急:一个<input type=text name=a >中只能录入数据,逗号,大于号,小于号,和等号,如何判断?
- 求助,开始菜单自动隐藏效果
- 頁面的Loaded狀態
- JAVASCRIPT能画圆,能画方吗?怎么画一个方呢?急!!!
"D:\wwwnew\WebApplication1\1.gif"
的话首先这个串就有问题。。
你可以alert下看看
我想这个串没有问题.
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> </HEAD>
<body>
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1" enctype="multipart/form-data">
<P>
<input name="file1" id="file1" type="file" onpropertychange="btn(this);" /><table id="imgfile" border="0">
<tr>
<td></td>
</tr>
</table>
<script language='javascript'>
function btn(obj)
{
var imgvalue=obj.value;
document.all('imgfile').rows[0].cells[0].innerHTML="<input type='image' onerror='alert(\"类型错误或者目标不存在!\");' src='"+imgvalue+"' alt='' border='0' width='30' height='30' onclick=\"javascript:window.open('"+imgvalue+"','','dialogWidth:500px; dialogHeight:500px; scroll:no; center:yes; help:no; resizable:no; status:no;');return false;\" />";}</script><input type="submit" name="Button1" value="Button" id="Button1" /></P>
<P><FONT face="宋体"></FONT> </P>
</form>
</body>
</HTML>
这样就没有错了.所以我想把字符串转成这样.我是ie6不行呀.
请问这个有什么办法解除吗?
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"></HEAD>
<body>
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1" enctype="multipart/form-data">
<P>
<input name="file1" id="file1" type="file" onpropertychange="btn(this);" /><table id="imgfile" border="0">
<tr>
<td></td>
</tr>
</table>
<script language='javascript'>
function btn(obj)
{
var imgvalue=obj.value;
imgvalue=imgvalue.replace(/\\/g,"\\\\");
document.all('imgfile').rows[0].cells[0].innerHTML="<input type='image' onerror='alert(\"类型错误或者目标不存在!\");' src='"+imgvalue+"' alt='' border='0' width='30' height='30' onclick=\"javascript:window.open('"+unescape(imgvalue)+"','','dialogWidth:500px; dialogHeight:500px; scroll:no; center:yes; help:no; resizable:no; status:no;');return false;\" />";
alert(document.all('imgfile').rows[0].cells[0].innerHTML)}</script><input type="submit" name="Button1" value="Button" id="Button1" /></P><P><FONT face="宋体"></FONT> </P>
</form>
</body>
</HTML>