This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Test</title> | |
<script src="//code.jquery.com/jquery-1.7.2.js"></script> | |
<script> | |
function GetUrlParameter(name) { | |
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | |
var regexS = "[\\?&]" + name + "=([^&#]*)"; | |
var regex = new RegExp(regexS); | |
var url = window.location.href; | |
url = "https://google.com?MyId=1934"; | |
var results = regex.exec(url); | |
alert(results); | |
if (results == null) | |
return ""; | |
else | |
return results[1]; | |
} | |
$(document).ready(function () { | |
var k = GetUrlParameter("MyId"); | |
alert(k); | |
}); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Or you can use below code to get Url Parameter
GetUrlKeyValue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Test</title> | |
<script src="//code.jquery.com/jquery-1.7.2.js"></script> | |
<script> | |
$(document).ready(function () { | |
var queryStringValue = GetUrlKeyValue('EditPage', window.location.href); | |
var queryStringValue1 = GetUrlKeyValue('EditPage', false, window.location.href); | |
var queryStringValue2 = GetUrlKeyValue('EditPage', true, window.location.href, false); | |
var queryStringValue3 = GetUrlKeyValue('EditPage', 'http://www.abc.com?EditPage=true'); | |
}); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |