Log in

View Full Version : Show a favicon based on the current URL for DotNetNuke



usheen
08-09-2008, 05:04 AM
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

rangana
08-09-2008, 08:15 AM
This might help:


<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>

usheen
08-09-2008, 08:37 AM
Thanks rangana,

That worked perfectly !

Regards,

Usheen