My bookmarklet opens a new window, if the window is already open I want to call .focus()
I have a bookmarklet that opens up a new window:
<a href="javascript:void(window.open(
'http://localhost:8080/myapp/query.jsp?u='+encodeURIComponent(location.href)+'t='+encodeURIComponent(document.title),
'query','status=0,toolbar=0,location=0,menubar=0,resizable=false,scrollbars=false,height=600,width=410'
));query.focus();">MyApp</a>
When the window is not open, this works fine as it gets opened and is visible.
But if the window was already open and I click the bookmarklet, I want the existing window to be made in focus and have the new data that is submitted be processed (if the page is different).
You can see I开发者_运维技巧 have tried to do this with query.focus();
but this doesn't seem to work.
Call focus()
on the window returned by window.open()
:
window.open(url, name, params).focus();
精彩评论