Solved

IE7 opens two browser windows instead of one

Posted on 2007-04-03
7
717 Views
Last Modified: 2013-11-19
I have a VB App that I wish to use to open a browser window with certain defined characteristics - no menu, no toolbar etc. I can do this using automation, but when I try to navigate to the URL I find with IE 7 I am getting two windows open. The first just says "connecting..." while the second opens to the correct URL, but with all the default browser settings - menu, toolbar etc. From searching around I can see this is because the new URL is in a different security context - in this case it is on the Intranet - but I have been unable to find a workaround to the problem.

I believe you get the same problem with JavaScript if you open a new window and then set the URL, where the new URL is in a non-default security context, such as HTTPS or on the intranet.
0
Comment
Question by:purplesoup
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:forrest321
ID: 18846376
Can you post the script you are using?
0
 

Author Comment

by:purplesoup
ID: 18849040
This is the JavaScript that has the same effect:

var winName = 'testwin';
var settings='width='+w+', height='+h+', top='+t+', left='+l+', scrollbars=yes, location=no, directories=no, status=yes, menubar=no, toolbar=no, resizable=yes';
var sURL='http://localhost/testsite/test_page.html';
var win1=window.open('',winName,settings);
if (win1==null) {
  alert ('unable to open a new window');
  return;
}

if (win1.history.length==0) {
  win1.location = sURL;
}

win1.focus();

There is nothing weird about this, it is simply opening a window and then setting the URL - if the URL is in a different security context you will get two windows open and the second will be in a default browser window.

The important point about the above JavaScript is that it has to be run in a web page opening via the file system, not from the local web site.

The same problem is reported at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1342849&SiteID=1  but there does not appear to be an answer given.

Note - as I say I am actually looking to do this from a Visual Basic application - it is just this problem also occurs via JavaScript.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 18849546
I don't have ie7 installed but just a thought.


can you disable to block the pop-up windows and try again?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:purplesoup
ID: 18849657
I think this might work with the JavaScript code - you could replace
var win1=window.open('',winName,settings);
with
var win1=window.open(sURL,winName,settings);

but in the Visual Basic code you *have* to create an instance of internet explorer before you call the navigate method and this results in a second browser opening, so it won't fix my real problem.
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 500 total points
ID: 18849948
0
 

Author Comment

by:purplesoup
ID: 18864827
I'm tempted to accept EDDYKT because I think I can use listing all open windows to work around this problem, however I would like to know if there is a way to really fix this problem. The basic problem appears to be that in Vista with IE 7 there is something called "protected mode" and if you initially create an internet explorer object - or do a window.open('') in JavaScript then protected mode is off, but if you then try to navigate the browser to a URL, or in JavaScript set the location property then typically you will navigate to a site where protected mode is on, and this will result in a second browser window opening.

Therefore is there a way to set the initial protected mode to "on", rather than off, so  it is possible to load the URL without opening a second browser?
0
 

Author Comment

by:purplesoup
ID: 18864992
OK - here is some more stuff.

It seems it is possible to use some new methods when using IE with automation to avoid these problems:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ietechcol/dnwebgen/protectedmode.asp

In particular it seems you should use IELaunchURL instead of Navigate().

http://msdn.microsoft.com/library/default.asp?url=/workshop/security/protmode/reference/functions/IELaunchURL.asp

However I would like to see a VB example on how to call this!

Second for the JavaScript code it seems you can use something called "mark of the web":  

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/motw.asp

This basically means putting something like this at the top of your page:
<!-- saved from url=(0014)about:internet -->

This will set your page to default to the internet zone and so any new page that launches from that page will also be in this zone (which will be in protected mode), however I now find that when I try to launch a new window I get an "access is denied" error.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now