Total members 11895 |It is currently Thu Dec 26, 2024 4:10 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Get window URL, page title and URL parameters
javascript code
<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>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : get url, title and url sent parameters with JQuery
 Post parameters using JQuery     -  
 Get values of Form parameters using JQuery     -  
 How to change this title • ?     -  
 remove page title     -  
 Reference Parameters     -  
 Encoding parameters in URL     -  
 Send parameters using HTTP GET     -  
 Method Parameters,,,is it by value or reference???     -  
 Function with default parameters     -  
 sending parameters into XSLT sheet     -  



Topic Tags

JQuery Validation
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
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