简体   繁体   English

停止 JavaScript 关闭 window

[英]Stopping JavaScript from closing a window

My company is required to use an application developed in ASP.NET by another company.我的公司需要使用另一家公司在 ASP.NET 开发的应用程序。 The application needs to be open in two separate browser windows. The company that developed the application has added some JavaScript at the top of the main page to stop user from opening multiple instances of the application.该应用程序需要在两个单独的浏览器 windows 中打开。开发该应用程序的公司在主页顶部添加了一些 JavaScript 以阻止用户打开该应用程序的多个实例。 The script that is placed at the top of the main page is as follows:放置在主页顶部的脚本如下:

<script type="text/javascript">
  function OpenApplicationWindow() {
    var sessionId = 'sidus455bjzspf55cunqrv55';
    if (window.name.search(sessionId) == -1) {
        window.open(window.location.href, sessionId, "resizable=yes,scrollbars=yes,toolbar=no,status=yes");
      window.open('', '_parent', '');
      window.close();
    }
  }
  OpenApplicationWindow();
</script>

Is there anyway to open a link to that page and allow more than one instance to open?无论如何打开该页面的链接并允许打开多个实例? Or is there anyway to stop that script from running.还是无论如何要阻止该脚本运行。

Short of disabling JavaScript (which would probably cause other problems), the only thing I can think of is to write a small proxy to strip that stuff out.除了禁用 JavaScript(这可能会导致其他问题)之外,我唯一能想到的就是编写一个小代理来剥离这些东西。

If you only need this on a few workstations, you could use Fiddler with the script editor to inspect and modify the response.如果您只在几个工作站上需要它,您可以使用带有脚本编辑器的 Fiddler 来检查和修改响应。

http://www.fiddler2.com/Fiddler2/version.asp -- download Fiddler http://www.fiddler2.com/Fiddler2/version.asp -- 下载Fiddler
http://www.fiddler2.com/fiddler/FSE.asp -- download the script editor. http://www.fiddler2.com/fiddler/FSE.asp -- 下载脚本编辑器。
http://www.fiddler2.com/Fiddler/Dev/ScriptSamples.asp -- see the example on this page to remove all div tags. http://www.fiddler2.com/Fiddler/Dev/ScriptSamples.asp -- 请参阅此页面上的示例以删除所有 div 标记。

You can use GreaseMonkey for IE , and create a small custom script to overwrite or remove the offending script.您可以使用GreaseMonkey for IE ,并创建一个小的自定义脚本来覆盖或删除有问题的脚本。

More information about using greasemonkey scripts in IE.有关在 IE 中使用 greasemonkey 脚本的更多信息

I suspect that the application attempts to block having multiple windows open at the same time to prevent race conditions caused by having two interfaces operating on the same session.我怀疑该应用程序试图阻止同时打开多个 windows,以防止由于两个接口在同一个 session 上运行而导致的竞争条件。

If you could have two windows open at once, it would probably break.如果你可以同时打开两个 windows,它可能会崩溃。

The simplest work around would be to run two separate browsers.最简单的解决方法是运行两个独立的浏览器。 Each one would get its own session and they wouldn't interfere with each other.每个人都会得到自己的 session,他们不会互相干扰。

The script that is stopping you opening another window is the 2nd parameter to the window.open which is sessionid阻止您打开另一个 window 的脚本是 window.open 的第二个参数,即 sessionid

It is checking that a window does not exist with that name already before opening it again.它正在检查 window 在再次打开之前不存在具有该名称的名称。

Not sure if thats what youre really asking or not tho.不确定那是否是您真正要问的。

If you are using Firefox you can code a greasemonkey script to override the JavaScript function.如果您使用的是 Firefox,您可以编写一个 greasemonkey 脚本来覆盖 JavaScript function。

try writing another function with the same name尝试写另一个同名的 function

OpenApplicationWindow打开应用程序窗口

that does nothing那什么都不做

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM