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 Link to comment https://forums.phpfreaks.com/topic/171064-solved-basic-problem-target_blank-inside-a-function/ 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). Link to comment https://forums.phpfreaks.com/topic/171064-solved-basic-problem-target_blank-inside-a-function/#findComment-902208 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. Link to comment https://forums.phpfreaks.com/topic/171064-solved-basic-problem-target_blank-inside-a-function/#findComment-902232 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? Link to comment https://forums.phpfreaks.com/topic/171064-solved-basic-problem-target_blank-inside-a-function/#findComment-902417 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. Link to comment https://forums.phpfreaks.com/topic/171064-solved-basic-problem-target_blank-inside-a-function/#findComment-902543 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? Link to comment https://forums.phpfreaks.com/topic/171064-solved-basic-problem-target_blank-inside-a-function/#findComment-902546 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.