首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

求解决拉 用什么方法能把"转意到页面上去啊解决办法

2012-01-01 
求解决拉用什么方法能把转意到页面上去啊?pageend+ scriptlanguage javascripttype text/javascript

求解决拉 用什么方法能把"转意到页面上去啊?
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 '>


function pagesubmits()
{{
location.href= " "{0}&pageno= " " + document.getElementById( 'locationpage ').value;
}}
</script> ",
url);


2. also, if u like

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


3.
深刻理解,
A.
C++++ 中 @ 在字符串的用法
B.
String.Format 的用法
C.
String.Format 中 { } 的转义
D.
javascript 字符串, ' (单引号) "(双引号),嵌套的转义用法

用好了 A B C ,其乐无穷,代码更加优雅,编码更加便捷


Hope helpful.

热点排行