473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

opening a new window from a HTA

There's a HTA application that's running on a local computer (not from a
URL) and the user can open a new HTML window by clicking a button

The first time the user clicks the button the window opens. Any
subsequent click causes this dialog, with this error, to appear:

"Error: The remote server machine does not exist or is unavailable"

The relevant code is

oline.onclick = function() {
if (outline.win && outline.win.open && !outline.win.closed) {
outline.win.focus();
} else {
outline.win = window.open(outline.fileName,"", "");
}
};

The MS script debugger claims the error is on the line that starts
"if (outline.win..."

Why does the error occur and how do I resolve it?

Andrew Poulos
Nov 14 '07 #1
3 10190
Andrew Poulos said the following on 11/14/2007 5:57 PM:
There's a HTA application that's running on a local computer (not from a
URL) and the user can open a new HTML window by clicking a button

The first time the user clicks the button the window opens. Any
subsequent click causes this dialog, with this error, to appear:

"Error: The remote server machine does not exist or is unavailable"

The relevant code is

oline.onclick = function() {
if (outline.win && outline.win.open && !outline.win.closed) {
outline.win.focus();
} else {
outline.win = window.open(outline.fileName,"", "");
}
};

The MS script debugger claims the error is on the line that starts
"if (outline.win..."

Why does the error occur and how do I resolve it?
My first guess would be that it can't get a proper handle on outline
after it has been opened. Does it happen whether the HTML window is open
or closed or only if it is opened?

Aside from that, can you post a URL to a sample .hta file?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 15 '07 #2
Randy Webb wrote:
Andrew Poulos said the following on 11/14/2007 5:57 PM:
>There's a HTA application that's running on a local computer (not from
a URL) and the user can open a new HTML window by clicking a button

The first time the user clicks the button the window opens. Any
subsequent click causes a dialog, with this error, to appear:

"Error: The remote server machine does not exist or is unavailable"

The relevant code is

oline.onclick = function() {
if (outline.win && outline.win.open && !outline.win.closed) {
outline.win.focus();
} else {
outline.win = window.open(outline.fileName,"", "");
}
};

The MS script debugger claims the error is on the line that starts
"if (outline.win..."

Why does the error occur and how do I resolve it?

My first guess would be that it can't get a proper handle on outline
after it has been opened. Does it happen whether the HTML window is open
or closed or only if it is opened?
The first time you click, the HTML window opens as expected.

If I leave the HTML window open and click the button in the HTA nothing
happens. That is, the HTML window stays behind the HTA though the HTML
window's task bar item flashs.

If I close the HTML window, the next time I click the button in the HTA
I get the error.

If I convert the HTA to a HTML page it runs the HTML window opens
without error in IE, Firefox, and Opera.

I tried wrapping the calls in try catch but it works for one case but
not others. At the moment I'm seeing if always closing the HTML window
in a try catch statement will make a positive difference.
Aside from that, can you post a URL to a sample .hta file?
Hmm, maybe but I'll have to created a pared down version so my manager
does come done on me.

Andrew Poulos
Nov 15 '07 #3
Andrew Poulos said the following on 11/14/2007 10:34 PM:
Randy Webb wrote:
>Andrew Poulos said the following on 11/14/2007 5:57 PM:
>>There's a HTA application that's running on a local computer (not
from a URL) and the user can open a new HTML window by clicking a button

The first time the user clicks the button the window opens. Any
subsequent click causes a dialog, with this error, to appear:

"Error: The remote server machine does not exist or is unavailable"

The relevant code is

oline.onclick = function() {
if (outline.win && outline.win.open && !outline.win.closed) {
outline.win.focus();
} else {
outline.win = window.open(outline.fileName,"", "");
}
};

The MS script debugger claims the error is on the line that starts
"if (outline.win..."

Why does the error occur and how do I resolve it?

My first guess would be that it can't get a proper handle on outline
after it has been opened. Does it happen whether the HTML window is
open or closed or only if it is opened?

The first time you click, the HTML window opens as expected.

If I leave the HTML window open and click the button in the HTA nothing
happens. That is, the HTML window stays behind the HTA though the HTML
window's task bar item flashs.
I made my own test page and I get the same thing except that the first
time I reclick it, it pulls the window up to the front. After that, it
flashes in the taskbar but won't bring it to the front.
If I close the HTML window, the next time I click the button in the HTA
I get the error.
I got the same thing.
If I convert the HTA to a HTML page it runs the HTML window opens
without error in IE, Firefox, and Opera.

I tried wrapping the calls in try catch but it works for one case but
not others. At the moment I'm seeing if always closing the HTML window
in a try catch statement will make a positive difference.
>Aside from that, can you post a URL to a sample .hta file?

Hmm, maybe but I'll have to created a pared down version so my manager
does come done on me.
I got interested and made my own.

This is the script I used in the .hta file:

var newWindow;
function openWindow(){

if (newWindow && newWindow.open && !newWindow.closed) {
newWindow.focus();
} else {
newWindow = window.open('test.html',"", "");
}
}

And the HTML:
<button onclick="openWindow()">Open a Window</button>

test.html was nothing more than a blank test page.

After getting the error and going through the if statement and trying to
narrow down the conditions to see which one was causing the error, I
tried something on a whim and it worked.

The problem seems to be that the HTA can't tell if the window is open or
not when it is closed. So, I set an onbeforeunload in the test.html file:

window.onbeforeunload = function(){window.opener.newWindow = null;}

After adding that to test.html, I never did get another error in the HTA
file.

Two things I did notice though. In an HTA file, if the variable
newWindow didn't exist, it threw an error in the if statement. Meaning,
without the var newWindow; line of code, IE7 was throwing an error on
the if statement. Adding it solved that issue.

Second, and it was more curiosity on my part, but, what is the point in
checking to see if the window is open (outline.win.open) and then
testing to see if it was "not closed" (!outline.win.closed). Seems
perverse to me.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dena Leiter | last post by:
I want to send people to a new page using a redirect but I want a new window to open. Is this possible? I've tried this: <meta http-equiv="refresh"...
44
by: Carlos Andr?s | last post by:
Hi everybody. I've got a problem. I'd like to avoid opening a new window when you have pressed the shift key and you click in the left button of the mouse. I've tried the next solution, in the...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
2
by: Keshav Gadia | last post by:
Hi, I am an ASP.net newbie. I am writing a user control that is made up of datagrid with one of the columns opening a new window to display some details on click of the set image. I have...
5
by: Roger Withnell | last post by:
This is a framed webpage with the navigation bar in "NavBar" and the main window in "Main". When opening a new page in "Main" from "NavBar" with: function OpenFrameWindow(src) { var...
3
by: Larry Bud | last post by:
Wanting to use a technology I saw for one of our apps. We have several apps that a user logs in at on the same page. The app is determined by a drop down. User credentials are checked,...
3
by: Bonzol | last post by:
Vb.Net 2003, 1.1. Web application. Hey there I have this, Response.Redirect("FileFiew.aspx") to go to a new page, but how do I open that page in a new window? So I will have 2 pages...
1
by: sandy21380 | last post by:
Hello, Is there a way of opening an Access form without opening the Access window? Right now when I open the form, the Access window is a lot bigger than the form so I have to resize the Access...
1
by: coolsidsin | last post by:
I have a apsx form (Form A), which on submiting does a time consuming task. So i want to open a new aspx window (Form B) in which I want do do that time consuming task and show progress to the user...
0
by: bbrewder | last post by:
I am struggling with some MSAccess automation issues. Basically, we have a .Net application that uses MSAccess for reporting (legacy code). We are able to launch MSAccess fine and even work with...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.