撇号在打开网站时会出现问题 [英] apostrophe causes problem in opening the website

查看:55
本文介绍了撇号在打开网站时会出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Response.Write("<script>window.open('http://www.micro'soft.com','_blank');</script>");





由于撇号错误。



我得到了一个网站,中间有撇号,如www.micro'soft.com



因为这个撇号网站没有正确加载



Error because of apostrophe.

I got a website which has apostrophe in the middle like this www.micro'soft.com

because of this apostrophe the website is not loading properly

推荐答案

撇号在域名中无效,它们可以在URL部分编码,但在根域中不允许使用。



你确定它不在URL而不是根域吗?
Apostrophe's are not valid in domain names, they can be encoded in the URL part, but they are not allowed in the root domain.

Are you sure its not in the URL instead of the root domain?


使用反斜杠来转义JavaScript字符串中的特殊字符,例如



Use backslash to escape special characters in JavaScript strings, e.g.

Response.Write(@"<script>window.open('http://www.domain.com/url-with-\'quote','_blank');</script>");





请注意我'我还将C#字符串更改为@字符串,这样您就不必转义C#代码中的反斜杠和引号。



我也改变了日e一个真实示例的URL,因为正如上面的人所说,域部分中带引号的URL无效,即使您正确格式化代码也无法工作。



Note that I've also changed the C# string to be a @ string so you don't have to escape the backslash and the quote in the C# code.

I've also changed the URL to a realistic example because as people above have said, a URL with a quote in the domain part is not valid and won't work even if you format the code correctly.


您好








使用& <而不是 '





Hi



use &apos; instead of '


Response.Write("<script>window.open('http://www.micro'soft.com','_blank');</script>");





参考: http://technet.microsoft.com/en-us/library /aa226544(v=sql.80).aspx [ ^ ]


这篇关于撇号在打开网站时会出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆