0

I am adding a class in document.write but it is not showing, below is my code.

new_window = open("","hoverwindow","width=600,height=300,left=10,top=10");
new_window.document.open();
new_window.document.write("<li>Dowload <a href=www.anylink.com class='help'></a></li>");

"help" is defined in my css file. Is the above syntax is correct for applying the class.

JN_newbie
  • 2,760
  • 8
  • 45
  • 79

3 Answers3

0

like @FrédéricHamidi sayd:

new_window = open("","hoverwindow","width=600,height=300,left=10,top=10");
new_window.document.open();    
new_window.document.write("<li>Dowload <a href='www.anylink.com' class='help'></a></li>");
RedDevil79
  • 460
  • 5
  • 13
0

Your anchor is empty:

<li>Dowload <a href=www.anylink.com class='help'></a></li>
                                                 ^--------

Change to:

<li><a href="www.anylink.com" class='help'>Dowload</a></li>
                                           ^^^^^^^-------
gdoron is supporting Monica
  • 136,782
  • 49
  • 273
  • 342
  • that help class has an image, but the image is not showing up. If I apply this class in any of the attribute in HTML it is working but not in document.write() – JN_newbie Feb 20 '13 at 09:52
0

Don't use document.write - it can cause you problems: Why is document.write considered a "bad practice"?

There are other ways of injecting HTML into pages using Javacsript - .innerHTML being a good example. JavaScript libraries like jQuery also have lots of options.

Community
  • 1
  • 1
James
  • 10,716
  • 1
  • 15
  • 19