2

I have this code which is broken. due to single and double quotes.

How should i escape it to get it working?

<a href="path" rel="example_group" title="<a href='/Home/Vote/@item.Id'><img src='/Content/images/021.png' style='float:left; margin-left:45%;' /></a><a onClick='window.open('test.com','sharer','toolbar=0,status=0,width=548,height=325');' href='javascript: void(0)'><img src='/Content/images/022.png' /></a>"><img  src="@Url.Action("ViewImage", "Image", new { id = item.Id, imageType="thumb" })" alt="" width="100" height="100" /> </a>

window.open is breaking it.

How can i fix this? I tried escaping but no luck.

Please see that this code is in Title of a. so I can't use double quotes.

Ray Cheng
  • 12,230
  • 14
  • 74
  • 137
DarthVader
  • 52,984
  • 76
  • 209
  • 300
  • at the end of `">` is that an erranious `"` at `">'` or am I mistaken? Because I see nothing matching with it at all. I believe you want a ` – Brendan Lesniak May 28 '12 at 01:59

1 Answers1

3

Use double quotes inside the single quotes.

<a onClick='window.open("test.com","sharer","toolbar=0,status=0,width=548,height=325");'

Or open and close it with double quotes

<a onClick="window.open('test.com','sharer','toolbar=0,status=0,width=548,height=325');"

EDIT

You can use &quot; in place of the double quote. If you need to write this HTML back out somewhere, you can replace the &quot; with " at that time.

EDIT

This similar SO question may help.

Community
  • 1
  • 1
jwatts1980
  • 7,254
  • 2
  • 28
  • 44