0

I have external JavaScript file with simple document.write() call. Problem is that a tag that i generate should open new browser window.

document.write('<a class="vcsupport" onclick="window.open("http://somesite.com/visitor/login.html","mywindow","location=0,status=0,scrollbars=0, width=500,height=500")" href="#"><img src="http://somesite.com/assets/en/someimage.gif" height="70" width="240" /></a>');

It doesn't work, doesn't open new browser window. I know something wrong but cannot figure what.

thanks

eugeneK
  • 9,954
  • 17
  • 64
  • 98
  • 1
    I'd say: don't use either. Popups are oldfashioned and annoying and can be replace with an overlayed html Element. `Document.write` is oldfashioned and can be replaced with innerHTML (of that overlayed html element). See also http://stackoverflow.com/questions/802854/why-is-document-write-considered-a-bad-practice – KooiInc May 19 '11 at 12:56

1 Answers1

1

You have: onclick="window.open("

The rules for quoting attributes still apply. You have to represent " characters as &quot; inside attribute values delimited by ".

Quentin
  • 800,325
  • 104
  • 1,079
  • 1,205