Solved

IE7 opens two browser windows instead of one

Posted on 2007-04-03
7
727 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
Technology Partners: 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What kind of script/language created this graph? 6 58
Make Float not to Wrap 15 63
Modify Text File with Excel Macro 13 44
Convert complicated date to yyyy-mm-dd format 22 45
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

738 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