View Full Version : how do I modify this script?

07-21-2005, 11:31 PM
I have the following script (which technically I got from Dynamic Drive but I couldn't find it again to reference which is why I'm posting here)

var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)

//if NS 4+
if (browser_type=="Netscape"&&browser_version>=4)
//if IE 4+
else if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4)
//Default goto page (NOT NS 4+ and NOT IE 4+)

Anyway, it works. What I like about it is the action happens onload - without a link having to be clicked or anything.
What I want it to do is not so much forward the page as open a new window with a defined url when the page the script is on loads.

So pretty much I want a "open a new window" script but without the necesseity of having to click on a link. Does that make sense?

Can it be done with this script or do I need a whole new script?


07-22-2005, 01:54 AM
Most modern browsers block all new windows not generated 'onclick' as pop-ups. You might be happy with an alert or a pop-up box of some kind. What exactly is the point of this? What would be in this new window?

07-22-2005, 04:05 PM
Yeah - I hadn't thought about pop up blockers.

I have a mysql database with a lot of articles in it for my business. But some articles that I want included I don't want to reprint because of possible copyright infringement.
Because of the structure I already have built on the site the easiest way to include them in the database seemed to be to have the title and author information and have the body be code that opens a new window with the article on the author's websites instead of making people click on up to 3 different links just to get to it.

07-22-2005, 08:06 PM
You can construct a link that will fire two page loads:

<a href="somepage.htm" onclick="window.open('another.htm');return true;">Dual Link</a>That shouldn't arouse the pop up blockers on all but the tightest security settings. This one may activate blocking but fires three links:

<a href="somepage.htm" onmousedown="window.open('another.htm');return true;" onmouseup="window.open('yetanother.htm');return true;">Triple Link</a>If you want the anchor link to open in a new window as well, add targeting:

<a href="somepage.htm" target="_blank" onclick="window.open('another.htm');return true;">Dual Link</a>

07-22-2005, 08:57 PM
cool. thank you.