Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: The Window.open File Within HREF Returns [OBJECT] in Current Window


View products that this article applies to.

Symptoms

The browser window's page disappears and is replaced by the word "[object]" when you use the following code to open a new window from an HREF:

<a href="javascript:window.open('http://www.microsoft.com');">Click here</a>
				

↑ Back to the top


Cause

This problem occurs because the browser is navigating to the window object returned by the Window.open file call.

This behavior is by design.

↑ Back to the top


Resolution

To resolve this problem, perform one of the following:
  • Add a void (0), as illustrated here, to give a no return value:
    <a href="javascript:window.open('http://www.microsoft.com'); void(0)">Click here</a>
    					
    -or-

  • Call your own JScript function to open a new window. This prevents the hyperlink navigation and allows you to retain a reference to the opened window.
    <SCRIPT>
    
    var childWin;
    
    function OpenUrl(url) {
    	childWin = window.open(url);
    }
    
    </SCRIPT>
    
    <a href="javascript:OpenUrl('http://www.microsoft.com');">Click here</a><p>
    						

↑ Back to the top


References

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

↑ Back to the top


Properties

Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

↑ Back to the top


Keywords: KB257321, kbscript, kbprb

↑ Back to the top

Article Info
Article ID : 257321
Revision : 3
Created on : 5/11/2006
Published on : 5/11/2006
Exists online : False
Views : 311