Solved

IE7 opens two browser windows instead of one

Posted on 2007-04-03
7
730 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

688 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