Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the script in javascript equals to $_SERVER['REQUEST_URI'] in php?

Tags:

javascript

I want to pass a URL to another domain through javascript appending iframe, when exit the iframe, the other domain can return the user to previous page on my site. If use php to submit the exit_url, it is

$exit_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "&request=example"";

I would like to learn how to convert this string to use in javascript. Thanks!

like image 443
Jenny Avatar asked Sep 03 '12 01:09

Jenny


1 Answers

You get the equivalent of $_SERVER['REQUEST_URI'] by appending location.pathname and location.search:

var request_uri = location.pathname + location.search;
like image 106
Ja͢ck Avatar answered Oct 20 '22 01:10

Ja͢ck