我有一个JSP页面,其中有JavaScript函数,当单击链接时会调用该函数。现在,当值到达JavaScript函数时,就会对撇号进行编码。
示例:
Name#039;s
在#之前有&;,最初应该是:
Name s
我使用了unescape()
解码函数,但似乎什么都不起作用。最后,我不得不删除字符并添加撇号。有人知道解决这个问题的办法吗?是JSP不支持对<code>&代码>?当我在这个页面中编写相同的编码值时,它将符号改为撇号,这正是我在代码中想要的。
我有一个JSP页面,其中有JavaScript函数,当单击链接时会调用该函数。现在,当值到达JavaScript函数时,就会对撇号进行编码。
示例:
Name#039;s
在#之前有&;,最初应该是:
Name s
我使用了unescape()
解码函数,但似乎什么都不起作用。最后,我不得不删除字符并添加撇号。有人知道解决这个问题的办法吗?是JSP不支持对<code>&代码>?当我在这个页面中编写相同的编码值时,它将符号改为撇号,这正是我在代码中想要的。
内置的Javascript函数,如unescape()
、decodeURIComponent()
与您正在处理的字符串无关,因为您要解码的是HTML实体。
Javascript中没有可用的HTML实体解码器,但由于您使用的是浏览器,如果字符串被认为是安全的,则可以执行以下操作(例如,在JQuery中)
var str = $( <p /> ).html(str).text();
它基本上将字符串作为HTML插入到<;p>
元素,然后提取其中的文本。
编辑:我只是意识到您发布的JSP输出不是真正的HTML实体;要处理给定的示例,您应该使用以下内容,添加&每个<code>#1234
并使其成为&#1234代码>:
var str = $( <p /> ).html(str.replace(/#(d+);/g &#$1; )).text();
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.
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 ...
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 ...
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 ...
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 ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
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.