Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Hiding a link if the domain matches the current url
Old 07-26-2011, 09:01 AM Hiding a link if the domain matches the current url
Spud In Disguise's Avatar
Super Spam Talker

Posts: 808
Location: UK... where else?
Trades: 0
Hi, can anyone suggest a suitable method for achieving the following:

I have a template that is used across several websites that requires the same file to be used. The template includes a link through to all of the sites that it is used on (for arguments sake lets say:
  • Site-a.com
  • Site-b.com
  • Site-c.com

I would like a piece of javascript that hides the link for the site you are currently viewing. So if you are viewing a page onwww.site-b.com you would only see the two links to site-a.com and site-c.com.

Thanks for any advice/help in advance.
__________________

Please login or register to view this content. Registration is FREE
- Fansite

Please login or register to view this content. Registration is FREE
- Blog
Spud In Disguise is offline
Reply With Quote
View Public Profile Visit Spud In Disguise's homepage!
 
 
Register now for full access!
Old 07-26-2011, 01:40 PM Re: Hiding a link if the domain matches the current url
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Why would you need to?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-26-2011, 02:21 PM Re: Hiding a link if the domain matches the current url
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
You can use something like document.location.href to detect the url of the page and using that hide/show the links you want.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 08-06-2011, 02:37 PM Re: Hiding a link if the domain matches the current url
Marik's Avatar
Skilled Talker

Posts: 99
Trades: 0
My raw js isn't very good so here's the jQuery version:

HTML Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {

    var presentDomain = document.domain;
    $('a').each(function() {
        var href = $(this).attr('href');
        if (href.search(presentDomain) != -1) {
            $(this).hide();
        }
    });

});
</script>
__________________

Please login or register to view this content. Registration is FREE
Marik is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Hiding a link if the domain matches the current url
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43937 seconds with 12 queries