Closed Bug 296153 Opened 20 years ago Closed 19 years ago

javascript code "window.focus()" throw NS_ERROR_FAILURE exception

Categories

(Toolkit Graveyard :: Error Console, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: rootcn, Unassigned)

Details

User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 2.0.40607)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; zh-CN; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

错误: uncaught exception: [Exception... "Component returned failure code: 
0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowInternal.outerHeight]"  
nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: 
file:///C:/Workspace/Internet/window.html :: wView :: line 16"  data: no]

Reproducible: Always

Steps to Reproduce:
my test htm file:
-------------------------
test.htm
----------
<script language="javascript">

var win;

function wOpen() {
	win = window.open("", "myWindow", "status=no");
}

function wView() {
	try {
		win.focus();
		alert(win);
	} catch (e) {
		alert(e);
	}
}
</script>

<input type="button" value="open" onclick="wOpen();" />
<input type="button" value="view" onclick="wView();" />

-------------------------
1. open a new window
2. close the opened window
3. execute javascript "win.focus()"
Actual Results:  
the exception can not be catched by javascript.

it seems throws a firefox exception/error.


Expected Results:  
throw a exception, at javascript, use "try ... catch ..." to catch.
Severity: blocker → normal
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b2) Gecko/20050531
Firefox/1.0+ ID:2005053122

No JSC errors
alert(e) gives [object Window]
in fact, i want know whether the opened window has been closed.

if the window closed, how can i know?

at IE , window.focus() will throw a exception.

but at Firefox, if you closed the window, the var 'win' still is the opened 
window object, it seems not judge the window is exist or not.
No JS Console messages here either. You can use win.closed to check if the&#10;window was closed.&#10;&#10;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b3) Gecko/20050712&#10;Firefox/1.0+
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → WORKSFORME
Product: Firefox → Toolkit
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.