Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript echo window.location

window.location = 'http://...';

now I want to assign this location path to a variable, as a normal text string. I want to achieve:

var Path = 'http://...';

i tried to use:

var Path = window.location;

but I get, as this var value:

function Path() { [native code] }

while I want to have the location text string as its value..

like image 920
serytankian Avatar asked Sep 06 '25 18:09

serytankian


2 Answers

You want location.href. The location object is rather more complicated than a simple string.

like image 145
Quentin Avatar answered Sep 09 '25 17:09

Quentin


This should work (though I didn't test):

var path = window.location.href;
like image 34
Arjan Avatar answered Sep 09 '25 19:09

Arjan