-3

How do I transform the first section of this document.write code into a popup link? Note the first part says "<a href=\"\/popups\/fed_budget.asp\"><img src=\"http:\/images\/video_graphic.jpg\, etc. How do I change that button link (video_graphic.jpg) to a popup instead of taking me to a different page? This is what I currently have:

document.write("<td width=\"251px\"><a href=\"\/popups\/fed_budget.asp\"><img src=\"http:\/images\/video_graphic.jpg\" alt=\"Video Graphic\" \/><\/a><\/td>");
document.write("<td style=\"padding-top:30px; padding-left:10px; padding-right:10px\">");

document.write("<b class=\"blue_text\">Recent News<\/b><br \/><br \/>");
document.write("<strong><a    href=\"\/news\/newshub\/articles\/federal_budget_2014.asp\">Your Federal Budget Update<\/a>  <\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b class=\"blue_text\">New<\/b><br    \/>");

document.write("Read our run-down on the super side of this year's Budget.<br \/><br   \/><br \/>");
document.write("<strong><a href=\"\/news\/newshub\/articles\/EOFY_Tips_tricks.asp\">EOFY tips and tricks<\/a><\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b class=\"blue_text\">New<\/b><br \/>");
document.write("Six strategies to help you get your super in shape.<br \/><br \/>");
document.write("<\/td>");
document.write("<\/tr>");
document.write("<\/table>");
Jacob
  • 77,566
  • 24
  • 149
  • 228
EF_1000
  • 45
  • 1
  • 6
  • 2
    Start with not using document.write, it overwrites the document if called after the document has originally loaded, and it's not recommended at all. Use DOM methods like appendChild, innerHTML etc. instead. – adeneo May 27 '14 at 07:38

2 Answers2

0

Popup link? Did you mean open it in a new tab ?

Just add attribute target="_blank" to the a tag.

Something like:

<a target="_blank" href="..."><img src="..." /></a>


Ps.: Avoid using document.write

target=“_blank” vs. target=“_new”
HTML <a> target Attribute

Community
  • 1
  • 1
w35l3y
  • 8,613
  • 3
  • 39
  • 51
0

If opening the link in another window is what you mean by "popup," the simplest thing for you to do would be to add a target attribute to your link, so it looks like this:

<a href="/popups/fed_budget.asp" target="_blank"><img src="http://images/video_graphic.jpg" alt="Video Graphic"/></a>

If, instead, you want to open this in a simplified new window, you'll have to use a JavaScript click handler that calls window.open:

<a href="#" onclick="window.open('/popups/fed_budget.asp')">...</a>

Oh, and I'd parrot the whole "don't use document.write ever" philosophy.

Jacob
  • 77,566
  • 24
  • 149
  • 228