开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜