Posted By

vanne on 04/18/07


Tagged

javascript


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

vali29
Leech


Retrieve domain name in javascript


 / Published in: Other
 

  1. var domain = "http://" + window.location.toString().split("//")[1].split("/")[0] + "/";

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: remysharp on May 10, 2007

Or:

var domain = 'http://' + window.location.hostname + '/';

Posted By: vanne on March 4, 2008

That's even better thanks!

You need to login to post a comment.