Solved

Invoking a new browser window with a hyperlink

Posted on 2002-06-07
26
253 Views
Last Modified: 2010-04-09
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
0
Comment
Question by:jcmeredith
  • 4
  • 4
  • 4
  • +7
26 Comments
 
LVL 5

Expert Comment

by:nfroio
Comment Utility
<A HREF="targeturl.html" TARGET="_top">Goto Page</A>

that should do you, the tricks in the Targeting
0
 
LVL 5

Accepted Solution

by:
nfroio earned 100 total points
Comment Utility
errr, actually, _top does not do the right thing, now that i re-read your question, I think that the _blank extension will actually be the one that opens a completely new window.

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

0
 
LVL 12

Expert Comment

by:lexxwern
Comment Utility
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>
0
 
LVL 17

Expert Comment

by:dorward
Comment Utility
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.
0
 
LVL 18

Expert Comment

by:bruno
Comment Utility
or

target="_new"


_top will just bust out of frames within the same window.
0
 
LVL 12

Expert Comment

by:lexxwern
Comment Utility
>> 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.
0
 

Expert Comment

by:Neroausity
Comment Utility
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.
0
 
LVL 17

Expert Comment

by:dorward
Comment Utility
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.
0
 
LVL 12

Expert Comment

by:lexxwern
Comment Utility
exactly,
the bottomline should now be _blank is for new windows and if you need more control use scripting.

anything from jcmeredith?
0
 
LVL 10

Expert Comment

by:dij8
Comment Utility
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).
0
 
LVL 18

Expert Comment

by:bruno
Comment Utility
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
0
 
LVL 10

Expert Comment

by:dij8
Comment Utility
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.
0
 
LVL 17

Expert Comment

by:dorward
Comment Utility
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
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Expert Comment

by:mouatts
Comment Utility
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 :)
0
 
LVL 18

Expert Comment

by:bruno
Comment Utility
gotcha.  :-)
0
 
LVL 12

Expert Comment

by:lexxwern
Comment Utility
re: anything from jcmeredith
0
 
LVL 17

Expert Comment

by:dorward
Comment Utility
mouatts: True, but due to the nasry urban myth of _new that makes it a very bad choice. Try something like mySiteDotComNEW
0
 
LVL 11

Expert Comment

by:mouatts
Comment Utility
dorward: I wasn't suggesting using it or maybe your sense of humour has just crashed.
0
 
LVL 18

Expert Comment

by:bruno
Comment Utility

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
0
 
LVL 10

Expert Comment

by:dij8
Comment Utility
nfroio wins the prize for this one (with an A of course).
0
 
LVL 5

Expert Comment

by:nfroio
Comment Utility
can't argue with sound reasoning and logic :-)

nfroio
0
 
LVL 11

Expert Comment

by:mouatts
Comment Utility
points to nfroio I suggest
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
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&
0
 
LVL 1

Expert Comment

by:Computer101
Comment Utility
Comment from expert accepted as answer

Computer101
E-E Moderator
0
 

Author Comment

by:jcmeredith
Comment Utility
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.
0
 
LVL 5

Expert Comment

by:nfroio
Comment Utility
No worries on my end, sorry to hear about the job, hope that you have found employment elsewhere...

nfroio
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now