Created
June 23, 2012 13:04
-
-
Save ww24/2978257 to your computer and use it in GitHub Desktop.
Window Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
window.openを置き換えることでopenに渡される引数を抜き出すことができます。
開いたWindowが同じドメイン、プロトコルであれば、Windowオブジェクトを参照することも可能です。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SOPを学ぶためのテストコード②です。
Chrome, Firefox, Safari, Opera, IE9でテストし、IE9だけ動かないことを確認しました。