window.opener alternatives

前端 未结 5 1843
生来不讨喜
生来不讨喜 2020-11-30 03:39

I am opening a modal popup window. Then I access a parent window textbox and other attributes using window.opener. It is working fine in firefox but not in IE8.

5条回答
  •  星月不相逢
    2020-11-30 03:45

    The approach I would take is the following:

    1. Use an existing JavaScript UI library because you are not the first person to ever want to do this, failing that
    2. Create a function called OpenWindow, that browser sniffs for the window.opener method

    For example:

    if(window.opener == undefined) {
       //probably not Firefox...
    }
    

    and if it finds it then uses it, else it tests for the IE variant and uses it. And then it checks Safari's version, etc...

提交回复
热议问题