Using jQuery to Display Previews For Only External Links

7 posts / 0 new
Last post
Anonymous

This is a rough design, but it works. Put it in the header.

<script type="text/javascript">
       $(document).ready(function() {
		$("a").each(function() {
			var cur_source = $(this).attr("href");
			if (cur_source) {
				if (cur_source.search("http://") != -1) {
					$(this).addClass("stwpopup");
				}
			}
		})
	});
</script>
puravida's picture
puravida
Jedi Warrior
Offline
Joined: 09/01/2007
Visit puravida's Website

Hi gpace and thanks for sharing your code!

So, to clarify for myself and other users, you would use the "mouseover preview bubble" code and then add the javascript code (previous post) to your page. Then, voila! Correct?

Thanks,

Brandon

Anonymous

Sorry, yes it is supposed to be used with the preview bubble code. The jQuery code goes through all the links on a page and adds a class to it if it has "http://" in it. You don't have to add anything to your links manually.

puravida's picture
puravida
Jedi Warrior
Offline
Joined: 09/01/2007
Visit puravida's Website
gpace wrote:
Sorry, yes it is supposed to be used with the preview bubble code. The jQuery code goes through all the links on a page and adds a class to it if it has "http://" in it. You don't have to add anything to your links manually.

Ohhh... that makes sense and now I understand the purpose better too.

Thank you for sharing!

Anonymous

Nice one... I do however have one concern or whatever I should call it...

Applying this to my site, makes every link sho a popup preview. Even those which are on my own site. How is it possible to exclude a domain in that piece of code you posted ?

The opposite of this I can do, hehe that's easy. It's just to add a domain name to:

Quote:
<script type="text/javascript">
$(document).ready(function() {
$("a").each(function() {
var cur_source = $(this).attr("href");
if (cur_source) {
if (cur_source.search("http://DOMAIN NAME.COM") != -1) {
$(this).addClass("stwpopup");
}
}
})
});
</script>

This is making every link WITHIN my domain use the preview, but no other. How can I make it the opposite, that is NOT show my internal links.

Regards Patric.

Anonymous

4 days and not even a glance at my post... let alone an answer... Ok, prolly not the service for me it seems.. Pitty as it seemed as a better service than most... to begin with

Bye.

puravida's picture
puravida
Jedi Warrior
Offline
Joined: 09/01/2007
Visit puravida's Website
Patric69 wrote:
4 days and not even a glance at my post... let alone an answer... Ok, prolly not the service for me it seems..

Bye.

Hi Patric69,

Saw your post days ago, but gpace is another member in the community. We cannot force them to respond and his mod is not directly supported by us. I think you may expect too much for the "free" service.

Best regards,

Brandon

ShrinkTheWeb® (About STW) is another innovation by Neosys Consulting
Contact Us | PagePix Benefits | Learn More | STW Forums | Our Partners | Privacy Policy | Terms of Use

Announcing Javvy, the best crypto exchange and wallet solution (coming soon!)

©2018 ShrinkTheWeb. All rights reserved. ShrinkTheWeb is a registered trademark of ShrinkTheWeb.