Solved

IE7 opens two browser windows instead of one

Posted on 2007-04-03
7
722 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

785 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