How can I get the domain name with jquery ??
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t need jQuery for this, as simple javascript will suffice:
See it in action:
For further domain-related values, check out the properties of
window.locationonline. You may find thatlocation.hostis a better option, as its content could differ fromdocument.domain. For instance, the urlhttp://192.168.1.80:8080will have only the ipaddress indocument.domain, but both the ipaddress and port number inlocation.host.