Jump to content

onClick: Double Quotation Mark Exempt


Cory

Recommended Posts

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

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

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

  • 2 months later...

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...