unistake Posted August 19, 2009 Share Posted August 19, 2009 Hi all, cant seem to find such a tutorial for this. I have a simple script: <script> function DoNav(theUrl) { document.location.href = theUrl; } </script> and this inside a html table <tr onclick=\"DoNav('$link');\" title='Click here'> The $link is an external website link. All I want is to open the link in a blank window - preferably a new tab. Please show me where to put target='_blank'. Thanks Tim Quote Link to comment Share on other sites More sharing options...
corbin Posted August 20, 2009 Share Posted August 20, 2009 Target is an attribute of a <a> tag, and document is a member of the document object... They're entirely unrelated. One way to do it would be to create a new window (a popup). Quote Link to comment Share on other sites More sharing options...
haku Posted August 20, 2009 Share Posted August 20, 2009 Change this: document.location.href = theUrl to this: window.open(theUrl, 'newwindow') But be warned that it won't work for anyone with a popup blocker. Quote Link to comment Share on other sites More sharing options...
unistake Posted August 20, 2009 Author Share Posted August 20, 2009 Thanks haku, so if anyones has a popup blocker, the link will not open at all? If this is the case, they get a message dont they if a popup is trying to execute? Quote Link to comment Share on other sites More sharing options...
haku Posted August 20, 2009 Share Posted August 20, 2009 Depends on their configuration I guess. I think I get a message every time. ...but I never open the popups, unless it's a site I absolutely know I can trust. Quote Link to comment Share on other sites More sharing options...
unistake Posted August 20, 2009 Author Share Posted August 20, 2009 ok thanks for that, i will bear it in mind . What is the alternative to pop-ups, new windows? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.