20
rated 0 times
[
25]
[
5]
/ answers: 1 / hits: 23943
/ 12 Years ago, sun, november 18, 2012, 12:00:00
I would like to change the URL that appears once a form has been submitted although the code below does not appear to do what I would like it to do. How do I change the URL in the address bar?
CODE
<!DOCTYPE html PUBLIC -//W3C//DTD XMHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
<html xmlns=http://www.w3.org/1999/xhtml xml:lang=en lang=en>
<head>
<meta http-equiv=content-type content=text/html;charset=UTF-8 />
<meta http-equiv=content-language content=en-us />
<meta http-equiv=cache-control content=no-cache />
<meta http-equiv=pragma content=no-cache />
<meta name=keywords content= />
<meta name=description content= />
<meta name=author content= />
<meta name=copyright content=© 2012 />
<meta name=robots content=noindex, nofollow />
<title>sample form</title>
<link rel=stylesheet type=text/css media=all href= />
<style type=text/css>
</style>
<script type=text/javascript>
var testurl = window.location.href;
if(testurl == file:///C:/Users/user/Desktop/sample_form.html?q=test&submit=submit) {
testurl = testurl.replace(/q=[^&]+&[a-z]+=[a-z]+/,'test');
alert(testurl);
}
</script>
</head>
<body>
<form name=sampleform id=sampleform method=get action=sample_form.html>
<input type=text name=q value= id=q />
<input type=submit name=submit value=submit id=submit />
</form>
</body>
</html>
More From » javascript