?
Solved

jscript, WHS,  WScript-how to detect if IE instance exists

Posted on 2007-10-10
2
Medium Priority
?
325 Views
Last Modified: 2008-01-09
Hello Experts:
I have jscript code that uses WScript to create an instance of IE and navigates to a specific URL on the localhost:

objIE = WScript.CreateObject("InternetExplorer.Application);
objIE.Visible = 0;
objIE.Navigate("URL_ON_LOCALHOST");

I want to make it visible depending upon other conditions, but my big problem is that I don't want to create another one if objIE already exists

How can I detect if objIE already exists?  Also where can I find a list of properties, such as the Navigate and Visible?  I tried objIE.Exists, hoping, but that is not one of them.  All I find searching is VB examples.

Also I have tried if(objIE) {
.....
}
 but this just stops the script execution..  

This is jscript, on Windows XP.

Please help!!!!!
Thanks!
Myra
0
Comment
Question by:mdolle
2 Comments
 
LVL 63

Assisted Solution

by:Zvonko
Zvonko earned 800 total points
ID: 20052300
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 1200 total points
ID: 20055100
An I suggest you do

var objIE=null; // make it global

function getIE() {
    if (objIE == null) objIE = WScript.CreateObject("InternetExplorer.Application);
    return objIE;
}


and use it later for example:

function something() {
  objIE = getIE(); // gets existing or creates a new
  objIE.Visible = 0;
  objIE.Navigate("URL_ON_LOCALHOST");
}

in function something, the name of the object does not need to be objIE:


function something() {
  myIE = getIE(); // gets existing or creates a new
  myIE.Visible = 0;
  myIE.Navigate("URL_ON_LOCALHOST");
}
 

will work too
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

809 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