
Skip to main content
How to get query string value in javascript
You can get the query string value in javascript by passing the query key to function and this function will return the value of this specific query key.
-
Get the query string value using javascript
<script> //URI = http://website.test/search?keyword=samar function GetParameterValues(param) { var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for (var i = 0; i < url.length; i++) { var urlparam = url[i].split('='); if (urlparam[0] == param) { return urlparam[1]; } } } var searchedKeyword = GetParameterValues('keyword'); console.log(searchedKeyword); //output : samar </script>
This code snippet will help you to get the query string value using javascript. You have to create a function which return the value of query string by specifying the query key to javascript function.
Bootstrap
Cmd
CodeIgniter
Css
Drupal
Git
Html
Javascript
Jquery
Laravel
Nodejs
Php
Python
Sql
Typescript
Wordpress
Random Code Snippet Queries: Javascript
- Javascript get only 10 characters from string
- Json stringify
- How to preview a word document in HTML using javascript
- How to make entire Div clickable in javascript
- ReferenceError: Cannot access 'myFunction' before initialization
- How to pass array as arguments to function in javascript
- How to Set data to localstorage in javascript
- How to open modal after redirect
- Check if value exists in array javascript
- Uncaught TypeError: Cannot read property 'addEventListener' of undefined
- How to add a property to object with condition in javascript
- How to preview video before uploading in javascript
- How to fixed bootstrap navbar at top on scroll
- How to remove duplicate values from array in javascript
- How can I add a key/value pair to a JavaScript object
- How to show and hide placeholder text
- How to get file extension using javascript/jquery
- How to get the length of a number in JavaScript
- Multidimensional array example javascript
- How to set href value of anchor tag in javascript
- Javascript get data-id attribute value
- How to check file is an image in javascript using filename
- How to crop multiple images with cropper js
- Javascript set timeout function with example code
- How to display for slash as a string in javascript HTML