Making a window pop under in chrome

前端 未结 8 1369
攒了一身酷
攒了一身酷 2020-12-03 05:55

I have a button that needs to open a new window as a popup (under the parent page). In IE/Firefox, it works fine, but in chrome the popup appears over (on top of) the parent

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 06:43

    You could also leave the popup behind, like this:

    var MINUTE_MILLISECONDS = 60000;
    var now = new Date().getTime();
    
    if (!localStorage.t || now > parseInt(localStorage.t) + MINUTE_MILLISECONDS) {
        var date = new Date();
        localStorage.t = now;
        window.location.href = "http://dgsprb.blogspot.com/";
        window.open(window.document.URL, "_blank");
    }
    

    This way the new content is left behind on the current tab, opening a new tab with the original window content. Works pretty much like a pop under, provided you can afford to reload the current window. You also ensure that the popup won't be shown more than once per minute.

提交回复
热议问题