开发者

How do i pass a javascript variable in querystring from one html page to other

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>


You 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.com/project/Cookie - no need to modify query string :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜