English 中文(简体)
2. 从扼杀中去除异子
原标题:Remove apostrophe from a string
  • 时间:2011-07-08 05:29:20
  •  标签:
  • javascript

我正在实施一项方案,使我能够利用Syntax(例如{Cli:FirstName})查询数据库领域,这是用户的第一名。 该方案允许我使用超文本和java文字在节目的窗口内展示一个网页。

我面临的问题是,我写了许多页和文字来显示正确的信息,但我发现问题。 我有文字说明,我把数据库的外地转至诸如职能之类的职能。

function a( {Cli:FirstName} }, {Cli:LastName} ){
logic;
}

我这样做是因为这一职能属于外部档案。 我使用的方案不允许我直接参考数据库领域,除非在方案窗口展示的.html档案中。 因此,在js的每一项职能都有类似的参数清单。 我可以在网页上写一个功能,直接进入数据库现场,而不把外地作为参数,但这会造成其他问题,而且由于显示网页的方案速度和其他限制,我几乎把所有文字移出。

The problem occurs when I try to pass a database field that has an apostrophe in it to a function in the.js file. It crashes the function call, since the apostrophe is a string delimiter. Some of the functions are event driven, but some are also when the page loads. The order of operations is that the program does the database query first, and then renders the html following normal flow for web pages. When, I load a page and a field has an apostrophe in it, and that is in a function call, I get an error message. Example Name: is O’Malley would crash the script. I need to fix it so after the database query is complete, I can go through the fields that I use as parameters in the functions and escape the apostrophe /’ before I pass into a function.

我的第一项想法是,在html网页上写出一个功能,因此,我可以直接进入数据库领域,然后越走热带,然后将这一价值传给其他职能。 这样,离热带迁移功能就足够笼统,足以为外向的其他地区工作。 我需要帮助说明如何写这一职能,然后将这一职能转给另一个职能。

function removeApostrophe (){
var firstName = ‘{CLI:FirstName}’; // sets the variable equal to the string in the database
  // do this for each field I use as a parameter in other functions
}
问题回答

为什么不只使用两字,而不用一字。

如果你没有能力控制其出现在超文本页上,就没有简单的解决办法。 如果你能够使用实体。 这并非完全安全,而是因为不能简单地把双引标划出:“

假设你在座标上不见两点引号。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签