admin管理员组文章数量:1414866
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 :)
本文标签: jqueryHow do i pass a javascript variable in querystring from one html page to otherStack Overflow
版权声明:本文标题:jquery - How do i pass a javascript variable in querystring from one html page to other - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745204012a2647543.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论