Cory Posted November 13, 2007 Share Posted November 13, 2007 Notice the single quotation marks highlighted in black? Those have to be double quotation marks in order for the onClick element to return the popup. Is there any possible way to exempt the double quotation marks and still have the onClick element return the popup? <a href="" onClick='return popup(this, 'DWNL')'></a> Link to comment Share on other sites More sharing options...
justsomeguy Posted November 13, 2007 Share Posted November 13, 2007 What's the problem with replacing the single quotes with double quotes? Link to comment Share on other sites More sharing options...
Cory Posted November 14, 2007 Author Share Posted November 14, 2007 Well, I have to host my HTML (using this method) on a particular page that can hold only so many characters. We have to either use the single quotation marks or the double quotation marks. Personally, I use double quotation marks around the HTML placed within the document.write line, which means I cannot use double quotation marks anywhere else. Link to comment Share on other sites More sharing options...
Synook Posted November 14, 2007 Share Posted November 14, 2007 You can escape the double quotes in you document.write statement like this: document.write("<a href=\"\" onclick=\"return popup(this, 'DWNL')\"></a>"); Link to comment Share on other sites More sharing options...
Cory Posted February 2, 2008 Author Share Posted February 2, 2008 Sorry to bump my old topic, but how would you escape the double quotes in the document.write statement when there is a link inserted in the hyperlink? Link to comment Share on other sites More sharing options...
Synook Posted February 2, 2008 Share Posted February 2, 2008 Err... example? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 4, 2008 Share Posted February 4, 2008 Escape all the quotes. If you need to escape the slashes also you can do that too. document.write("<a href=\"java script:void(0);\" onclick=\"alert('This text is \\\"quoted\\\")');\"></a>"); Link to comment Share on other sites More sharing options...
Cory Posted February 5, 2008 Author Share Posted February 5, 2008 Can you give an example of that with the link inserted?Like so: <a href="http://209.85.12.236/7627/25/upload/p7757365.jpg" onClick="return popup(this, 'D')">Preview</a> I want to escape the quotation marks in that. Link to comment Share on other sites More sharing options...
boen_robot Posted February 5, 2008 Share Posted February 5, 2008 Can you give an example of that with the link inserted?Like so:<a href="http://209.85.12.236/7627/25/upload/p7757365.jpg" onClick="return popup(this, 'D')">Preview</a> I want to escape the quotation marks in that. I'd do:document.write('<a href="http://209.85.12.236/7627/25/upload/p7757365.jpg" onClick="return popup(this, \'D\')">Preview</a>'); (i.e. escape only the single quotes inside)If that doesn't work, then document.write("<a href=\"http://209.85.12.236/7627/25/upload/p7757365.jpg\" onClick=\"return popup(this, 'D')\">Preview</a>"); (pretty much invert the above) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.