Access a window by window name

后端 未结 7 1167
悲哀的现实
悲哀的现实 2020-11-29 07:08

If I open a window using

window.open(\'myurl.html\', \'windowname\', \'width=100,height=100\');

How do I refer to the new window (from the

7条回答
  •  攒了一身酷
    2020-11-29 07:44

    In firefox (might work in other browsers too, but now it's not my concern) I was able to reference one window accross multiple page loads with

    var w = window.open("", "nameofwindow");
    

    This opens new window if it doesn't exist and return reference to existing window if it does exist without changing contents of the window.

    With jQuery I was then able to append new content, to make quick collection of interresting links like this

    $('body', w.document).append(link_tag);
    

提交回复
热议问题