Skip to content

Instantly share code, notes, and snippets.

@ww24
Created June 23, 2012 13:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ww24/2978257 to your computer and use it in GitHub Desktop.
Save ww24/2978257 to your computer and use it in GitHub Desktop.
Window Manager
window.windowManager = (function () {
var orgOpen = open,
windows = [];
window.open = function () {
var win = orgOpen.apply(null, arguments);
windows.push({
option: arguments,
window: win
});
return win;
};
return windows;
})();
// Usage
console.log(windowManager);
@ww24
Copy link
Author

ww24 commented Jun 23, 2012

SOPを学ぶためのテストコード②です。
Chrome, Firefox, Safari, Opera, IE9でテストし、IE9だけ動かないことを確認しました。

@ww24
Copy link
Author

ww24 commented Jun 23, 2012

window.openを置き換えることでopenに渡される引数を抜き出すことができます。
開いたWindowが同じドメイン、プロトコルであれば、Windowオブジェクトを参照することも可能です。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment