Thu Jan 10, 2013 12:45 am
<html>
<head>
<title>print URL, Title and URL sent parameters</title>
<!--
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
Note you can download the JQuery package instead of using Google version. -->
<script src="jquery-1.8.3.js"></script>
<script>
$(document).ready(function(){
$("button#btn1").click(function(){
//For:
//http://localhost/JQuery/QueryStart.html?username=mess&age=34&address=USA
// Get Parameter value with name = username
$("div").html($.urlParam('username')+"<br/>");
// Get Parameter value with name = age
$("div").append($.urlParam('age')+"<br/>");
// Get Parameter value with name = address
$("div").append($.urlParam('address')+"<br/>");
});
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
$("button#btn2").click(function(){
var URL = window.location.href;
$("div").html('<strong>' + URL + '</strong>');
});
$("button#btn3").click(function(){
var title = $(document).attr('title');
$("div").html('<strong>' + title + '</strong>');
});
});
</script>
</head>
<body>
<p style="background:#1414A4;color:yellow;width='50';"
width="200"><b>Show Url Parameters</b></p><br>
<div></div>
<button id="btn1">Show Parameters</button>
<button id="btn2">Show URL</button>
<button id="btn3">Show Page Title</button>
</body>
</html>
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.