How to Make a Link Open into a New Page
Highlight the words
you wish to be the hyperlink and press CNTL-K. In the dialog box that
opens, enter the URL into the address bar. Now on the right where it says
target window, click that and choose New Window. This will add:
target="_blank"
to the a element.
See the
Video Tutorial of How to Make a Link Open into a New Page.
There is no Attribute "TARGET"
If you take a look at the
HTML A Element,
you will see that target is not recognized in Strict XHTML as your
DOCTYPE.
For more information, please check out
I was Strict but now I need to be Transitional
and
Target Not Allowed in XHTML - Using JavaScript.
I use
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
if(!anchors[i].href.match('www.loudexpressions.com/'))
{anchors[i].target = "_blank";}
}
}
window.onload = externalLinks;
and I save it with a .js extension (external-window.js). I insert
it into my pages using a
virtual path:
<script type="text/javascript" src="/includes/external-window.js">
</script>
This will help to make sure that any links not pointing to
www.loudexpressions.com
will open in a new window. And the path is pushed back to the
root. Of course, you can also use a
relative path as well:
<script type="text/javascript" src="../includes/external-window.js">
</script>
Just make sure that the path is correct and the links will open in a new window.
If you have any questions, please ask in the
International Web
Developers Network forum.




Comments