B_Dorsey
asked on
window.location - How about just the domain?
window.location is for the current document URL, how about just the domain?
I am trying to set the homepage but it uses the long URL (including the querystring)
Thanks
Bill D
I am trying to set the homepage but it uses the long URL (including the querystring)
Thanks
Bill D
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Uhps! It looks like window.location.domain is not a property.
Try then:
window.location.host
Try then:
window.location.host
Try also:
document.domain
document.domain
Do not thrust those properties too much. Not all browsers fill them. In Opera for one you cannot really rely on anything but location.href.
So for the domain I would do a quick parse:
var temp = window.location.href.split ("/");
var domain = temp[2]; // you may still need to peel of port number and such.
So for the domain I would do a quick parse:
var temp = window.location.href.split
var domain = temp[2]; // you may still need to peel of port number and such.
ASKER
I cant get any of these to work for some reason, maybe I cant use it in the spot I want to .... see below
<script language="JavaScript">
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVer sion) >= 4)) {
document.write("<A HREF=\"javascript:window.e xternal.Ad dFavorite( window.loc ation.href );\" ");
document.write("onMouseOve r=\"window .status=") ;
document.write("'Bookmark this site'; return true;\" ");
document.write("onMouseOut =\"window. status=");
document.write("' '; return true;\"");
document.write("><img src=\"/images/browser_sett ings/bookm ark_ie.gif \" width=\"186\" border=\"0\" height=\"30\"></a>");
}
else {
document.write("<img src=\"/images/browser_sett ings/bookm ark_other. gif\" width=\"186\" border=\"0\" height=\"30\">");
}
</script>
Also by chance where in this code would I put the name of the bookmark?
Thanks Guys
Bill D
<script language="JavaScript">
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVer
document.write("<A HREF=\"javascript:window.e
document.write("onMouseOve
document.write("'Bookmark this site'; return true;\" ");
document.write("onMouseOut
document.write("' '; return true;\"");
document.write("><img src=\"/images/browser_sett
}
else {
document.write("<img src=\"/images/browser_sett
}
</script>
Also by chance where in this code would I put the name of the bookmark?
Thanks Guys
Bill D
ASKER
Its in this line that Im trying to make it work
document.write("<A HREF=\"javascript:window.e xternal.Ad dFavorite( window.loc ation.href );\" ");
Bill D
document.write("<A HREF=\"javascript:window.e
Bill D
try this:
document.write("<A HREF=\"#\" onclick=\"window.external. AddFavorit e(window.l ocation.hr ef);return false\" ");
document.write("<A HREF=\"#\" onclick=\"window.external.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
window.location is an object. It evaluates to a String.
But that object has several properies.
In your case you should use: window.location.domain
Look also for: window.location.URL and window.location.href
Good luck,
NetGroove