Problem printing and redirecting jquery firefox

1

Good evening, I write this time because I am trying to print a div and then redirect me to the main page, but the problem is that it does not redirect me, I try in firefox and that happens to me, it's as if I just made an action print nothing more, how could I make it work for me?

This is the code I am using, some idea to solve this problem:

$(document).on('ready',function (e){
$(".testbutton").click(function () {
    $("div#myPrintArea").printArea();
    setTimeout(function(){ 
        $(location).attr('href','/inicio/'); 
    },2000);
});
});
    
asked by Teresa 13.04.2017 в 02:04
source

3 answers

2

Hello, use some of the following alternatives to redirect, both are valid.

window.location.replace('/inicio/');

or

window.location.href = '/inicio/';

Greetings.

    
answered by 13.04.2017 / 02:16
source
1

It is not necessary to use jQuery to wrap location . To perform a redirect, you can do it using the replace method or simply overwriting the href property:

location.relace('/inicio');

You can also do it using assign :

location.assign('/inicio/');

The difference between replace and assign is that the first replaces the current entry in the history, while assign creates a new one.

    
answered by 13.04.2017 в 02:37
0

But I'm wrong the $ location should be an exact address, not a folder

$(document).on('ready',function (e){
$(".testbutton").click(function () {
    $("div#myPrintArea").printArea();
    setTimeout(function(){ 
        $(location).attr('href','/inicio/index.php'); 
    },2000);
});
});
    
answered by 13.04.2017 в 02:25