【问题标题】:Back to previous page when using document.write使用 document.write 时返回上一页
【发布时间】:2015-06-09 03:09:37
【问题描述】:

我使用 dropzone.js 上传文件。 这是我的代码

Dropzone.options.myDropzone = {
      url: 'teacher.php?action=teacher_class_member_csv_form_confirm', 
      addRemoveLinks: true,
      autoProcessQueue: false,
      autoDiscover: false,
      paramName: 'csv', 
      clickable: true, 
      accept: function(file, done) {
        done();
      },
      error: function(file, msg){
        alert(msg);
      },
      init: function() {
        var myDropzone = this;
        jQuery("#sbmtbtn").click(function(e) {
           e.preventDefault();
           e.stopPropagation();
          // var queuedFiles = myDropzone.getQueuedFiles();
           myDropzone.processQueue();
        });

      },
      success: function(file, response) {
          //jQuery("#myDropzone").submit();
          //window.history.pushState({"html":response,"pageTitle":response.pageTitle},"", 'teacher.php');
          document.write(response);
          history.pushState(null, null, 'teacher.php');
      }
  };

当 ajax 进程完成时,它会响应一个模板。我正在使用document.write 来显示该模板。

但是当我在浏览器中单击返回按钮时,我无法转到上一页。

请帮助我。 对不起,如果我的英语不好。

【问题讨论】:

  • 你的意思是说浏览器中的后退按钮吧?
  • 是的,是浏览器的返回按钮
  • 后退按钮不起作用,因为您在同一页面上书写,您没有导航到新页面以使后退按钮起作用
  • 当我点击返回按钮时,url 改变但浏览器不刷新,它一直处于加载状态

标签: php dropzone.js


【解决方案1】:

如果我猜对了,你想回到当前 url 之前的一、两页吗?你也可以用document.write写这个

<a href="javascript:history.go(-2);"> go back 2 pages </a>

没有足够的代表,应该是评论,我猜

【讨论】:

  • 我想点击浏览器的后退按钮返回上一页。但是当我点击它时,url改变但页面内容没有加载,它保持在加载状态
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-02
  • 1970-01-01
相关资源
最近更新 更多