简体   繁体   中英

Stopping JavaScript from closing a window

My company is required to use an application developed in ASP.NET by another company. 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. 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.

If you only need this on a few workstations, you could use Fiddler with the script editor to inspect and modify the response.

http://www.fiddler2.com/Fiddler2/version.asp -- download Fiddler
http://www.fiddler2.com/fiddler/FSE.asp -- download the script editor.
http://www.fiddler2.com/Fiddler/Dev/ScriptSamples.asp -- see the example on this page to remove all div tags.

You can use GreaseMonkey for IE , and create a small custom script to overwrite or remove the offending script.

More information about using greasemonkey scripts in IE.

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.

If you could have two windows open at once, it would probably break.

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.

The script that is stopping you opening another window is the 2nd parameter to the window.open which is sessionid

It is checking that a window does not exist with that name already before opening it again.

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.

try writing another function with the same name

OpenApplicationWindow

that does nothing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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