Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting full URL with jQuery including parameters after question mark?

I am trying to use jQuery to get the current full URL of a page. The URL of a page looks like this:

http://myurl.com/ebook?page=43

If I use window.location.pathname it only returns everything before the ? so I would just get

http://myurl.com/ebook

How can I get the entire URL?

like image 477
user13286 Avatar asked Feb 10 '14 17:02

user13286


People also ask

How to get the full URL in jQuery?

The current URL in jQuery can be obtained by using the 'href' property of the Location object which contains information about the current URL. The 'href' property returns a string with the full URL of the current page.

How can get current URL with parameters in jQuery?

In JavaScript, just use window. location. href, and in JQuery use code $(location). attr('href'), both will return the current URL.

How to pass Value through URL in Javascript?

Given a URL and the task is to add an additional parameter (name & value) to the URL using JavaScript. URL. searchParams: This readonly property of the URL interface returns a URLSearchParams object providing access to the GET decoded query arguments in the URL.

How do I find the parameter of a URL?

Method 1: Using the URLSearchParams Object The URLSearchParams is an interface used to provide methods that can be used to work with an URL. The URL string is first separated to get only the parameters portion of the URL. The split() method is used on the given URL with the “?” separator.


1 Answers

You have:

window.location.href 

and also:

document.URL 
like image 95
Mehran Hatami Avatar answered Sep 24 '22 08:09

Mehran Hatami