Forum Moderators: open

Message Too Old, No Replies

onClick='top.location.href=url to Open New Window

         

peterinwa

8:15 pm on Mar 8, 2005 (gmt 0)

10+ Year Member



The above works fine in a page with JS and Frames, but it replaces my webpage with the target URL in the current window. I want it to open a new window.

I tried to slip in target="_blank" but got an error.

I'm guessing there's syntax to replace the top.location, but also curious why the target="_blank" didn't work:

b2+="<table width=500 bgcolor='#000000' cellpadding=2 cellspacing=0 align=center onClick='top.location.href=\"URL\" target=\"_blank\"' onMouseOver='this.style.cursor=\"pointer\"'><tr><td>";

Thanks, Peter

Bernard Marx

8:56 pm on Mar 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



b2+= ...?

Perhaps a little more code might shed some light :)

peterinwa

11:41 pm on Mar 8, 2005 (gmt 0)

10+ Year Member



b2 is just part of a table and it all works fine.

The only "problem" is that I want to know how to change top.location.href to make it open a new window.

Thanks, Peter

peterinwa

11:56 pm on Mar 8, 2005 (gmt 0)

10+ Year Member



Here's the whole thing but without the target=_blank that you see in my first post that caused the error message:

b1="<table width=500 bgcolor='#000000' cellpadding=2 cellspacing=0 align=center onClick='top.location.href=\"URL\"' onMouseOver='this.style.cursor=\"pointer\"'><tr><td>";
b1+="<table width=100% bgcolor='#33cc33' cellpadding=1 cellspacing=0><tr><td>";
b1+="<table width=100% bgcolor='#000000' cellpadding=1 cellspacing=0><tr><td>";
b1+="<table width=100% bgcolor='#ffff99' cellpadding=0 cellspacing=0><tr><td align=center class='bannerText'>";
b1+="Text goes here...";
b1+="</td></tr><tr><td align=center valign=top class='bannerSubText'>";
b1+="More text goes here...";
b1+="</td></tr></table></td></tr></table></td></tr></table></td></tr></table>";

Bernard Marx

1:02 am on Mar 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The target attribute only goes on links (or frames).

Try the window.open() method instead.

peterinwa

4:19 am on Mar 9, 2005 (gmt 0)

10+ Year Member



Thanks, Peter