Monday, November 10, 2014

Way to get url, protocol in javascript

First get the current address
var url = window.location.href
Then just parse that string
var arr = url.split("/");
your url is:
var result = arr[0] + "//" + arr[2]

No comments:

Post a Comment