How to retrieve GET parameters from javascript

0 votes
For js within page.html,how can it retrieve GET parameters?

For the below simple example,func('returnurl') should be /admin

http://domain.com/page.html?returnurl=%2Fadmin

But it should also work for complex querystrngs. How to do that?

Sep 21, 2020 in Java-Script by kartik
• 37,510 points
364 views

1 answer to this question.

0 votes

Hello @kartik,

This code gives you GET without the question mark.

window.location.search.substr(1)

From your example it will return returnurl=%2Fadmin

Hope it helpss!!

Thank you!!

answered Sep 21, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

How to get the URL without any parameters in JavaScript?

Hello @kartik, This is possible, but you'll have ...READ MORE

answered Oct 9, 2020 in Java-Script by Niroj
• 82,880 points
5,551 views
0 votes
1 answer

How to get the host url using javascript from the current page?

Hello @kartik, Use: var host = window.location.hostname; or possibly var host ...READ MORE

answered Oct 9, 2020 in Java-Script by Niroj
• 82,880 points
982 views
0 votes
1 answer

How to get the browser to navigate to URL in JavaScript?

Hii, This works in all browsers: window.location.href = '...'; If ...READ MORE

answered May 28, 2020 in Java-Script by Niroj
• 82,880 points
2,396 views
0 votes
1 answer

How to Get values from a specific user - queryset in Django?

Hello @kartik, You can get the list of Users ...READ MORE

answered May 28, 2020 in Java-Script by Niroj
• 82,880 points
10,413 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
21,916 views
0 votes
1 answer

What is type casting and type juggling in php?

Hey, The way by which PHP can assign ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
6,840 views
0 votes
2 answers

How can we create a session in PHP?

Hello, niroj. Here is my idea session_start(); $_SESSION['USERNAME'] ...READ MORE

answered Dec 7, 2020 in PHP by Famous
• 140 points
936 views
0 votes
1 answer

What is the use of $_REQUEST variable in php?

Hii @kartik, The $_REQUEST variable is used to read the ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
2,818 views
0 votes
1 answer

How to access GET directly from JavaScript?

Hello @kartik, You can first go through: window.location.search It will ...READ MORE

answered Apr 29, 2020 in Java-Script by Niroj
• 82,880 points
2,023 views
0 votes
1 answer

How to get the file name from a full path using JavaScript?

Hello @kartik, Use this: var filename = fullPath.replace(/^.*[\\\/]/, '') This ...READ MORE

answered Sep 2, 2020 in Java-Script by Niroj
• 82,880 points
1,131 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP