0

我正在研究 jquery 和 javascript。有没有办法让页面刷新并恢复被点击的相同链接。例如。在 gmail.com 中,当我们打开窗口左侧的已发送项目并刷新页面时。它会重新加载相同的已发送项目选项卡的内容,刷新时收件箱和草稿的内容相同。有没有其他方法或例子来实现这一点。如果是。请帮忙。将不胜感激。

这是我在刷新时刷新页面的代码:

<script>
   $(window).load(function(){
  $(function()
   {
    $('#submit').click(function()
      { 
          $('.container').show();
          $('#login').hide();
            $.cookie('shown', true);
            });
          if ($.cookie('shown')) {
              $('#submit').click()
          }
        });
     });  

   </script>
4

2 回答 2

1

这是一个示例 ajax 表单提交脚本。

// this is the id of the submit button
$("#submit").click(function() {

    var url = "path/to/your/script.php"; // the script where you handle the form input.

    $.ajax({
           type: "POST",
           url: url,
           data: $("#idForm").serialize(), // serializes the form's elements.
           success: function(data)
           {
               alert(data); // show response from the php script.
           }
         });

    return false; // avoid to execute the actual submit of the form.
});
于 2013-07-01T09:38:34.130 回答
0

假设您正在使用 Ajax 来更改页面状态,为什么不看看History.js 之类的东西呢?

于 2013-07-01T09:26:47.720 回答