函数里的参数带有单引号怎么办,穿出去的值有问题,而且参数不能修改,因为是文件名,请看下面代码
<A href=\"javascript:openpic('"+pdfpath+"')\" >clickhere</A>
function openpic(picpath){
picpath=escape(picpath);
//从这里传出去的picpath就是空值了
window.open("customershowpic.jsp?path="+picpath);}
<A href=\"javascript:openpic('"+pdfpath+"')\" >clickhere</A>
function openpic(picpath){
picpath=escape(picpath);
//从这里传出去的picpath就是空值了
window.open("customershowpic.jsp?path="+picpath);}
var picpath=escape(picpath);
<A id="aa" >clickhere</A>
$("#aa").click(function(){
var picpath=escape(picpath); window.open("customershowpic.jsp?path="+picpath);
});
<A href=\"javascript:openpic('"+pdfpath+"')\" >clickhere</A>
+号在js中工作
如果这个A标签是在html中的话,我没有什么方法。
用js去生成的话倒是可以,或者你直接把'换成%27好了。<A href="javascript:openpic('%27picpath')" >clickhere</A><html>
<script>
function dosomething(){
var d = document.getElementById("123");
var abc = "a'b";
d.innerHTML = "<a href=\"" + escape(abc) + "\">domlink</a>";
}
</script>
<body onload="dosomething()">
<div id="123"></div>
</body>
</html>