It is currently Thu Sep 09, 2010 12:48 pm

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How to Make button and Image Links open in a new window HTML
New postPosted: Sun Nov 23, 2008 11:55 am 
Offline
Site Admin

Joined: Mon Jun 09, 2008 10:09 am
Posts: 455
Location: East Coast USA
When you're linking to a page on another website, it's good to have it open in a new window so you don't lose visitors to that site. Learn how to control that with a little HTML code.

1. Create an external link to a website
2. Go to the HTML of the page --
3. Find the link that you created. If the link I created was for the phrase "AdminXL" linking to the AdminXL.com website

<a href="http://www.adminxl.com">AdminXL webmaster Forum</a>

4. Add the following little tid-bit of code that appears in bold to that line of code..
<a target="_blank" href="http://www.adminxl.com">AdminXL Webmaster Forum</a>

dont forget the " after _blank.. or it wont work.. :-D


Top
 Profile  
 
 Post subject: Re: How to Make button and Image Links open in a new window HTML
New postPosted: Tue Dec 02, 2008 8:10 am 
Offline
Apprentice

Joined: Tue Dec 02, 2008 7:57 am
Posts: 4
OR

You can try this out, it took quite long to cusomise how i wanted but here you go..

Code:
<script type="text/javascript">
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=anchors.length-1; i>=0; i--) {
var anchor = anchors[i];
if (anchor.href && !(anchor.href.substr(0,9) == "http://fo"))
anchor.target = "_blank";
anchor.rel = "nofollow";
}
}
window.onload = externalLinks;
</script>


If your website is haha.com then replace http://fo with http://ha to prevent local links opening in a new window.

EnjoY!


Top
 Profile  
 
 Post subject: Re: How to Make button and Image Links open in a new window HTML
New postPosted: Wed Dec 03, 2008 12:50 pm 
Offline
Site Admin

Joined: Mon Jun 09, 2008 10:09 am
Posts: 455
Location: East Coast USA
thank you for sharing that little piece of code umarsa :-D

havent tested it out yet.
but I will :-D


Top
 Profile  
 
 Post subject: Re: How to Make button and Image Links open in a new window HTML
New postPosted: Tue Dec 16, 2008 5:32 pm 
Offline
AdminXL Mod

Joined: Fri Jul 04, 2008 8:18 pm
Posts: 86
Thank you this is really helpful, i have always used a javascript code. This is so much easier!

_________________
Cyber Wrld - Online Today!


Top
 Profile  
 
 Post subject: Re: How to Make button and Image Links open in a new window HTML
New postPosted: Fri Jan 30, 2009 4:29 pm 
Offline
Apprentice XL

Joined: Sat Dec 27, 2008 7:01 pm
Posts: 33
The Javascript looks nice. I knew this already though... :lol:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB3 © 2009 phpBB Group