Link to home
Start Free TrialLog in
Avatar of jcmeredith
jcmeredith

asked on

Invoking a new browser window with a hyperlink

What is the HTML syntax for creating a hyperlink that will, when selected by the visitor to my website, will invoke a new browser window instead of driving the visitor from my website?

i using a simple text editor to create my web pages.

many thanks,

this is probably an easy one but as i am not sure, 100 points are offered....

;-)

chris
Avatar of nfroio
nfroio
Flag of United States of America image

<A HREF="targeturl.html" TARGET="_top">Goto Page</A>

that should do you, the tricks in the Targeting
ASKER CERTIFIED SOLUTION
Avatar of nfroio
nfroio
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes, blank is the correct target.

this can be done with javascript too.

like this

<a href="#" onclink="javascript:window.open('hello.html','new window','height=  , width=  , scroll=yes/no, status=yes/no, address=yes/no')">link</a>
Avatar of dorward
dorward

Doing it with JavaScript is a rather nasty solution, if the user disables JS or uses a browser that doesn't support JS then it will not work (and some users are physically incapable of using browsers that support JS so this would be tantamount to discriminating against the disabled).

If you want to suggest a size for the window then you should provide a raw HTML backup, like so:

<a href="file.html" target="foo" onclick="if (window.open) { window.open(this.href,this.target,'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,width=200,height=100'); return false; } else { return true; };">link</a>  (replace "foo" with a name unique to your site, e.g. mySiteDotComTerms)

Although many users find popup windows irritating, I find its generally best to stick to the one window.
or

target="_new"


_top will just bust out of frames within the same window.
>> Doing it with JavaScript is a rather nasty solution,
i agree but you then have a more control

bruno,

target = "Anything Not Defined" will open in a new window, you know what i mean, try it out. but i dont really recommend this.
Hello there! What I have found that works just fine for me (of course, my site uses frames) is this:

target="null"

That way, when the link has that included, it will open a completely different pop up window, that the user can close without being directed away from your site.
target="null" just creates a window called "null" in the same way that lexxwern explained.

_new though /really/ should be avoided. A myth has grown up that it creates a new unnamed window - it doesn't. If two sites both try to link to _new then they will interfere with each other.

Use _blank for a new window you don't plan to use, and something unique if you plan to reference it again from the site.
exactly,
the bottomline should now be _blank is for new windows and if you need more control use scripting.

anything from jcmeredith?
There are a multitude of other solutions but the most basic and strictly HTML solution is target="_blank".  http://www.w3.org/TR/html4/types.html#type-frame-target

nfroio wins the prize for this one (with an A of course).
dorward,

if another site tried to link to _blank after you've opened the window, it wouldn't open in the same window as well?


BRUNO
BRUNO, _blank is an HTML convention and will ALWAYS open a new window.  I guess it creates a unique ID so will never reference _blank as a named window.
brunobear: Correct, as the specification says

The following target names are reserved and have special meanings.

_blank
The user agent should load the designated document in a new, unnamed window.

_self
The user agent should load the document in the same frame as the element that refers to this target.

_parent
The user agent should load the document into the immediate FRAMESET parent of the current frame. This value is equivalent to _self if the current frame has no parent.

_top
The user agent should load the document into the full, original window (thus canceling all other frames). This value is equivalent to _self if the current frame has no parent.

http://www.w3.org/TR/html4/types.html#h-6.16
Actually using an undefined window name is sometimes a good idea in that if someone hits your link for the first time it opens up a new window, if they hit it a second time whilst the window still exists it will use that window again. Which means that the user doesn't end up with hundred of browser windows open!

Not heard of _new before, nice to know that someone out there is generating new Internet Myths :)
gotcha.  :-)
re: anything from jcmeredith
mouatts: True, but due to the nasry urban myth of _new that makes it a very bad choice. Try something like mySiteDotComNEW
dorward: I wasn't suggesting using it or maybe your sense of humour has just crashed.

Hello,

This question has been open for quite a while now and needs to be wrapped up.

EXPERTS: If any of the experts could come back and post any suggestions as to how they feel this could be wrapped up (delete, 0 PAQ, award points, etc), I'm sure the moderators would appreciate it.  If you feel you deserve points here, but don't care to respond, the question might very well get DELETED.

ASKER:  Please return and finalize this question.  Abandoning a question is in violation of the member agreement.

Please do NOT accept this comment as an answer, as I am simply trying to alert those involved that the question is still open.

Thank you,

BRUNO
nfroio wins the prize for this one (with an A of course).
can't argue with sound reasoning and logic :-)

nfroio
points to nfroio I suggest
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to nfroio

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
Comment from expert accepted as answer

Computer101
E-E Moderator
Avatar of jcmeredith

ASKER

my apologies for abandoning this question. i lost my job abruptly and this project was taken over by someone else. i won't let it happen again.
No worries on my end, sorry to hear about the job, hope that you have found employment elsewhere...

nfroio