Results 1 to 3 of 3

Thread: Show a favicon based on the current URL for DotNetNuke

  1. #1
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Show a favicon based on the current URL for DotNetNuke

    I'm trying to build a script that will check the current URL/domain and return the appropriate favicon.

    This is for a DotNetNuke installation where the same default.aspx is used for all parent and child sites regardless of domain alias.

    So in my case the portal is ABDomain.com which is the parent.

    Then I have a child of the parent which resolves to XYDomain.com

    Both XY and AB use the same default.aspx and therefore the same favicon is displayed.

    So my script would check what domain is currently the URL e.g http://www.XYDomain.com and show the specific favicon for that domain.

    I'm unsure as to whether or not this can actually work, but if anybody can help I appreciate it.

    Usheen

    Example:

    If URL = ABDomain.com then show http://www.ABDomain.com/favicon.ico
    Else
    If URL = XYDomain.com then show http://www.XYDomain.com/favicon.ico

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    This might help:
    Code:
    <script type="text/javascript">
    window.onload=function(){
    var url=location.href, // Checks the corrent location
    // You could also specify a "fix" url
    uri1='http://www.XYDomain.com', // first url
    uri2='http://www.ABDomain.com', //Second url
    link=document.createElement('link'); // create a <link> tag
    link.setAttribute('rel','shortcut icon');
    link.setAttribute('type','image/x-icon');
    if(url.toLowerCase()==uri1.toLowerCase())
    link.setAttribute('href',uri1+'favicon.ico'); // href will appear as http://www.xydomain.com/favicon.ico
    else link.setAttribute('href',uri2+'favicon.ico'); // href will appear as http://www.abdomain.com/favicon.ico
    document.getElementsByTagName('head')[0].appendChild(link);
    }
    </script>
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Perfect

    Thanks rangana,

    That worked perfectly !

    Regards,

    Usheen

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •