문제

Suppose I have a JavaScript bookmarklet. When I press this button I would like it to open three predefined URLs and perform an action (clicking the logout button, for example) on each one. If I were doing this with only one site, I could do window.open("http://stackoverflow.com","_self") and then document.getElementById('logout').click()

Is there a way I can have this action performed simultaneously in different tabs? If not, how would I go about switching tabs?

도움이 되었습니까?

해결책

You can't.

Switching tabs is beyond what content-level JavaScript has security permissions to do. As far as one JavaScript instance is concerned, there only exists one tab (window).

You would need to write an extension for your browser of choice.

If you're writing for Chrome, check out some documentation on the APIs for tab manipulation with extensions.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top