How to make Links open in a New Window?

admin

Administrator
Staff member
Hello, I was wondering how to make all the links on my website open up in a new window when clicked. Thats all...Thanx in advance to all who reply.<br />
<br />
Sincerely,<br />
Jason<!--content--><a href=http://www.htmlforums.com/archive/index.php/"page.html" target="_blank"></a><br />
<br />
<br />
Gandalf<br />
:D<!--content-->Do i have to post this (<a href=http://www.htmlforums.com/archive/index.php/"page.html" target="_blank"></a>) on every one of the links i have? Or is there a way to make it default to open up in a new window?<!--content-->You must use the target="_blank" attribute for every link you want to open in a new window. There isn't a way to make a class for all of the links, at least that I'm aware of.<br />
<br />
<br />
Gandalf<br />
:D<!--content-->Ok thank you. Thats exactly what i needed to hear.<br />
<br />
Wait....One more thing. I was just tried that code and its not working right. Can u check out my source and see if you can find what im doing wrong? I want the menu linked to html forums.com and htmlhelp.com to open in a new window<!--content-->As far as having to use the 'target="_blank"' for every link it seems like there was a way to keep from having to do all that. I think it was something you put in the head of every html document. If I run across the answer I'll let you guys know. Oh, by the way, where's the link for your site shooter555? <br />
Derek<!--content-->This would go in the <head> to automatically configure all your links on a page to open in a new window. <br />
<br />
<base href=http://www.htmlforums.com/archive/index.php/"your link.html"><br />
<br />
Derek<!--content-->Here are some different options for the target attribute.<br />
<br />
target="_blank" (opens link in new window with no name)<br />
target="_new" (opens link in new windows called, new)<br />
target="_top" (opens link in same window)<br />
<br />
This attribute was originally used to open links outside of framed sites. "_top", would open a link in the same browser, but over all of your frames.<br />
<br />
But this attribute doesn't hold specifically to framed sites.<br />
<br />
<br />
Gandalf<br />
:D<!--content-->This would go in the <head> to automatically configure all your links on a page to open in a new window. ~ Derek02<br />
<br />
<br />
Ah, yes! I forget about that one a lot. <br />
<br />
Detailed <base> info here: <!-- m --><a class="postlink" href="http://www.w3schools.com/tags/tag_base.asp">http://www.w3schools.com/tags/tag_base.asp</a><!-- m --> <br />
<br />
A correction to my previous post:<br />
<br />
target="_new" attribute is not a W3C standard, but does work. However, I suggest learn it correctly, so you don't have to relearn them later.<br />
<br />
These are the correct values for the target attribute:<br />
<br />
_blank - all the links will open in new windows <br />
_self - all the links will open in the same frame they where clicked <br />
_parent - all the links will open in the parent frameset <br />
_top - all the links will open in the full body of the window <br />
<br />
<br />
Gandalf<br />
:D<!--content-->my website is <!-- m --><a class="postlink" href="http://www.freewebs.com/myflashanimations">http://www.freewebs.com/myflashanimations</a><!-- m --><br />
<br />
ps. i am a beginner at programming and am still constructing the site<!--content-->Check this link out: <!-- m --><a class="postlink" href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.freewebs.com%2Fmyflashanimations%2F&charset=%28detect+automatically%29&doctype=HTML+4.01+Transitional&ss=1&outline=1&sp=1&verbose=1">http://validator.w3.org/check?uri=http% ... &verbose=1</a><!-- m --> and post again if you get stuck on any of these errors.<!--content-->Sorry guys, I screwed up. It should be...<br />
<br />
<base target="_blank"><br />
<br />
If you code to XHTML standards then the 'target="_something"' won't be valid. Someone on another forum recommended opening a new window with Javascript to get around this. But you should be okay coding for 4.01. <br />
Derek<!--content-->
 
Back
Top