I have two html pages example1.html and example2.html ,how can i pass a javascript variable username from example1.html to example2.html in querystring.
<script type="text/javascript" >
$(document).ready(function() {
$('#SubmitForm').submit(function() {
var username = ($("#username").val());
...........
..........
..............
.........
</script>
<body>
<div id="example2"><a href="http://localhost:1894/blockseek8-9-2010/example2.html?Var1=username" class="MainNav"></a></div>
</body>
I have two html pages example1.html and example2.html ,how can i pass a javascript variable username from example1.html to example2.html in querystring.
<script type="text/javascript" >
$(document).ready(function() {
$('#SubmitForm').submit(function() {
var username = ($("#username").val());
...........
..........
..............
.........
</script>
<body>
<div id="example2"><a href="http://localhost:1894/blockseek8-9-2010/example2.html?Var1=username" class="MainNav"></a></div>
</body>
Share
Improve this question
edited Sep 16, 2010 at 8:27
Delan Azabani
81.6k30 gold badges172 silver badges212 bronze badges
asked Sep 16, 2010 at 8:26
maheshmahesh
3,21717 gold badges72 silver badges131 bronze badges
3 Answers
Reset to default 2You can modify the href attribute of your link:
$("#example2 a").attr("href", url + "?var1=" + username);
If username uses special characters you will need to url encode it.
You could either use PHP, or set location.search
.
What about using cookies? http://plugins.jquery./project/Cookie - no need to modify query string :)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745204013a4616496.html
评论列表(0条)