Making a window pop under in chrome

前端 未结 8 1336
攒了一身酷
攒了一身酷 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条回答
  •  Happy的楠姐
    2020-12-03 06:28

    This code works up to Chrome 65:

    function just_open() {
        postMessage([...arguments]);
    }
    window.onmessage = function({data}){
        return open(...data);
    }
    function openunder() {
        just_open([...arguments]);
        window.open().close();
    }
    

    Where openunder is just like open() except:

    • no return value
    • No Chrome 65+, uses https://crbug.com/833148

提交回复
热议问题