Welcome to DU! The truly grassroots left-of-center political community where regular people, not algorithms, drive the discussions and set the standards. Join the community: Create a free account Support DU (and get rid of ads!): Become a Star Member Latest Breaking News Editorials & Other Articles General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

Website, DB, & Software Developers

Showing Original Post only (View all)

Jesus Malverde

(10,274 posts)
Sun Jan 12, 2014, 09:11 PM Jan 2014

Javascript pros, code help needed..... [View all]

Last edited Sun Jan 12, 2014, 11:08 PM - Edit history (1)

I have an applescript that uses javascript to take the current selected text in safari, opens a new window, goes to the GD new post form and sets the title and body.

My problem is, if my selected text contains a quote, than the javascript will fail. How do I escape the quotes in javascript.

I'm using the following javascript. Keep in mind it's written to be fired by applescript.

do JavaScript &quot ''+getSelection())" in document 1)

do JavaScript "
document.forms['form2']['title'].value = '" & thename & "' ;
document.forms['form2']['message-text'].value ='" & newselectedText & pageURI & "' ;" in doc

How do I tell javascript to treat +getSelection like string and not text...

Peace and TIA.

If any high post count peeps want the complete applescript... send me a pm.

8 replies = new reply since forum marked as read
Highlight: NoneDon't highlight anything 5 newestHighlight 5 most recent replies
Javascript pros, code help needed..... [View all] Jesus Malverde Jan 2014 OP
Off the top of my head... hootinholler Jan 2014 #1
Thanks for your help on this one. Jesus Malverde Jan 2014 #2
The first thing to remember about javascript is hootinholler Jan 2014 #3
Message auto-removed Name removed Oct 2020 #6
Message auto-removed Name removed Jun 2020 #4
Message auto-removed Name removed Sep 2020 #5
Message auto-removed Name removed Jul 2021 #7
Thank you radhashetty Jun 2023 #8
Latest Discussions»Retired Forums»Website, DB, & Software Developers»Javascript pros, code hel...»Reply #0