/    Sign up×
Community /Pin to ProfileBookmark

Unable to change ' back to ‘

Hello

I have created a page that takes several txt inputs and outputs html and javascript code to be copied and pasted by the user into a html capable text area of a document in creation.
when that document in creation is loaded by the user it creates a popup window filled with textual info adjacent to their main content.
Problem: I am able to convert the text in which contains apostrophes to “'” so that they don’t break the code lines but not able to convert them back once the content is finally displayed on the final page.

[CODE]
clnParaOne = txtParaOne.replace(/’/g,’'’);
var output =”//code to output”;
+”var popup=window.open(‘_blank’,”,’width=1280,height=1024,”+marginLeft+”,top=0′);”
[/CODE]

the line below is giving me problems:

[CODE]
+”popup.document.write(‘document.getElementById(\’copy\’).textContent.replace("'"\/g,"\’");’);”
[/CODE]

[CODE]
+”popup.document.write(‘<body onload="xyZ()">’);”
+”popup.document.write(‘<div class="title">”+txtHeadline+”<\/div>’);”
+”popup.document.write(‘<br>’);”
+”popup.document.write(‘<div id="copy">’);”
+”popup.document.write(‘”+clnParaOne+”‘);”
+”popup.document.write(‘<\/div>’);”
+”popup.document.write(‘<\/body>’);”
+”popup.document.write(‘<\/html>’);”
+”popup.document.close();”
[/CODE]

this is for an extremely controlled environment on an isolated intranet so its exclusive to ie 7/8. I know this is a syntax error but i cant find it

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@JonaNov 01.2010 — [font=arial]Hi,

You are missing a forward slash at the beginning of your Regular Expression, and quotes around your replacement value. Try something like the following.[/font]

<i>
</i>+"popup.document.write('document.getElementById(\'copy\').textContent.replace([b][color=red]/[/color][/b]&amp;quot;[b][color=red][/color][/b]&amp;apos;&amp;quot;\/g,[b][color=red]\'[/color][/b]&amp;quot;\'&amp;quot;[b][color=red]\'[/color][/b]);');"
Copy linkTweet thisAlerts:
@savvykmsNov 02.2010 — Perhaps this will work?

escaped = unescaped.split("'").join("&apos;");
×

Success!

Help @Reahreic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...