Back to previous page when using document.write

560 views Asked by At

I use dropzone.js to upload file. Here is my code

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');
      }
  };

When ajax process done, it response a template. I'm using document.write to display that template.

But when I click to back button in browse, i can't go to previous page.

Please help me. Sorry if my English not good.

1

There are 1 answers

1
AudioBubble On

if i get you right,you want to go back,like one,two pages before the current url ? you can also write this using document.write

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

not enough rep,should have been a comment,i guess