Victor Kimura
asked on
get subdomain of url
Hi,
I wish to grab the subdomain portion of a url using javascript. I have this client's url:
http://medicaid-florida.medicaidconsultants.com/
I want to grab only the portion 'medicaid-florida' and save it to a variable.
Is there an easy way to do this?
Thank you,
vkimura
I wish to grab the subdomain portion of a url using javascript. I have this client's url:
http://medicaid-florida.medicaidconsultants.com/
I want to grab only the portion 'medicaid-florida' and save it to a variable.
Is there an easy way to do this?
Thank you,
vkimura
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi govindarajan78,
What's the difference between the two?
What's the difference between the two?
the location.host will omit the file names & querystrings if any
function getSubDomain()
{
var str = "http://medicaid-florida.medicaidconsultants.com/"
var arrValue = str.split("//");
var arrSecondValue = arrValue[1].split(".");
var result = arrSecondValue[0];
alert(result);
}