如何让浏览器保持当前窗口 [英] How to tell browser to stay on current window

查看:191
本文介绍了如何让浏览器保持当前窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我做一个window.open()有没有办法告诉浏览器留在当前窗口或标签,而不是去新标签页或窗口?

When I do a window.open() is there a way to tell the browser to stay on the current window or tab and not go to the new tab or window?

推荐答案

发现在原始窗口中调用javascript的方法是使用 self.focus()。从阅读该讨论中得到以下结果:防止window.open聚焦

Found that a way to do this is with self.focus() in the javascript called from the original window. Got this from reading that discussion: Prevent window.open from focusing.

所以我的代码看起来像这样。

So my code looks like this.

    $.ajax({ 
        url : "filename.php", 
        dataType: "html", 
        success : function (data) { 
            $('#div').html(data);
            $('#div2').css('visibility','hidden');
        } 
    });

    var external_window = window.open(url,'_blank');
    self.focus();

这篇关于如何让浏览器保持当前窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆