<!-- JavaScript:Extras code snippet 9. -->
<!-- Capturing the 'get' method attribute query string
from a URI. -->
<!-- JavaScript:Extras code snippet 9 go forward first page. -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Code source: http://www.justfigures.co.uk/ -->
<!-- A resource for web developers using XHTML, CSS, JavaScript, PHP -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Go forward page</title>
</head>
<!-- first create a link with a query string -->
<body>
<a href="9_queryStringA.html?value=My%20query%20string">Click here to go forward first with the query string '?value=My%20Query%20string'.</a>
</body>
</html>
<!-- JavaScript:Extras code snippet 9 second page called '9_queryStringA.html' -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Code source: http://www.justfigures.co.uk/ -->
<!-- A resource for web developers using XHTML, CSS, JavaScript, PHP -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>View code snippet page</title>
<script language="JavaScript" type="text/javascript">
/* Function to capture the unescaped value of the
'get' method attribute query string */
function queryStringValue() {
var queryString = location.search
/* unescape the query string to remove '%20',
which is the hexadecimal equivalent of the space character */
queryString = unescape(queryString)
/* remove '?value=' from the query string
to leave just the query string value */
queryString = queryString.substring(7)
return queryString
}
</script>
</head>
<body>
<script language="JavaScript" type="text/javascript">
document.write("The full query string in the URI is: "+location.search+'<br />')
document.write("The unescaped query string with '?value=' removed is: "+queryStringValue())
</script>
</body>
</html>