日期:2014-05-18  浏览次数:20405 次

求解决拉 用什么方法能把"转意到页面上去啊?
pageend   +=   " <script   language= 'javascript '   type= 'text/javascript '> ";
pageend   +=   "function   pagesubmits() ";
pageend   +=   "{ ";
pageend   +=   "location.href= ' "   +   url   +   "&pageno= '+document.getElementById( 'locationpage ').value; ";
pageend   +=   "} ";
pageend   +=   " </script> ";

url   = "a.aspx?where=images <> ' ' ";

结果郁闷的是程序执行后成了pageend   +=   "location.href= 'a.aspx?where=images <> ' '&pageno= '+document.getElementById( 'locationpage ').value; ";

老是提示我有脚本错误缺少;,原来是里面 '号截断了JS字符串,
请问有什么转意符号能把location.href= ' "   +   这的单引号转意成别的么,然后输出到页面上的时候变成双引号,这样JS就没问题了
期待高手帮忙


我试了一下“\ "”     但是pageend   +=   "location.href=\ " "   +   url   +   "&pageno=\ "+document.getElementById( 'locationpage ').value; ";还是不行

期待高手

------解决方案--------------------

直接这样呢:
pageend += "location.href= " + url + "&pageno="+document.getElementById( 'locationpage ').value; ";
------解决方案--------------------
string url = "a.aspx?where= "+Server.UrlEncode( "images <> ' ' "); string pageend = " <script language= 'javascript ' type= 'text/javascript '> "; pageend += "function pagesubmits() "; pageend += "{ "; pageend += "location.href=\ " " + url + "&pageno=\ "+document.getElementById( 'locationpage ').value; "; pageend += "} "; pageend += " </script> "; Response.Write(pageend);
------解决方案--------------------
string url = "a.aspx?where= "+Server.UrlEncode( "images <> ' ' ");

string pageend = " <script language= 'javascript ' type= 'text/javascript '> ";
pageend += "function pagesubmits() ";
pageend += "{ ";
pageend += "location.href=\ " " + url + "&pageno=\ "+document.getElementById( 'locationpage ').value; ";
pageend += "} ";
pageend += " </script> ";

Response.Write(pageend);
------解决方案--------------------
// maybe, more elegant style
//

// ...
url = "a.aspx?where=images <> ' ' ";
//
pageend += String.Format(
@ " <script language= 'javascript ' type= 'text/javascript '>
function pagesubmits()
{
location.href= " "{0}&pageno= " " + document.getElementById( 'locationpage ').value;
}
</script> ",
url);
------解决方案--------------------
1.
sorry, ->

// ...
url = "a.aspx?where=images <> ' ' ";
//
pageend += String.Format(
@ " <script language= 'javascript ' type= 'text/javascript '>