Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2004, 05:11 AM
Registered User
 
Join Date: Jul 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default [object window] ???

Hello, i have the following code:
Code:
<a href="javascript:window.open('doc3.htm', '', 'width=100,height=200,scrollbars=yes,resizable=yes');">
the above code surely does open the new window like the way i want, but in the original window(where the above code is) it loads some page with the text [object window] and in the addressbar with the above code(javascript:window.open('doc3.htm', '', 'width=100,height=200,scrollbars=yes,resizable=yes ').

can anyone please tell me why this is so, and how i can solve it???
i want the window to be completely closed except for the newly opened one whic for the above code would be 'doc3.htm'

thanks!

 
Old July 31st, 2004, 02:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

if u give name to ur Window they will all open in that window & wont open new window.
Sorry if I didnt get ur problem well. Tell me if Im wrong & explane what u want more.

Always:),
Hovik Melkomian.
 
Old September 9th, 2004, 04:48 AM
Authorized User
 
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try this one :

function open()
{
     window.open('*.html', '//name', '//properties and values');
}
<body>


 
Old September 9th, 2004, 04:49 AM
Authorized User
 
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try this one :

function open()
{
     window.open('*.html', '//name', '//properties and values');
}
<body>
     <a href="javascript:open()" onclick="open()">Open Window</a>
</body>

Best regards,
Randhy

 
Old September 9th, 2004, 05:16 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You won't be able to close the original window across all browsers unless you opened it via script.
You can avoid the [object window] text by ignoring the return value in the JavaScript.
Code:
<a href="javascript:void(window.open('doc3.htm', '', 'width=100,height=200,scrollbars=yes,resizable=yes'));">
Personally I would use onclick event rather than JavaScript pseudo protocol and return false from function to prevent unwanted side effects. This also gives some functionality to non JavaScript users:
Code:
function openChildWindow(Url)
{
  var oChild = window.open(Url, null, 'width=100,height=200,scrollbars=yes,resizable=yes');
  self.close(); //Warning displayed
  return false;
}
<a href="doc3.htm" onclick="openChildWindow(this.href);">Open Child</a>
--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
Centering Popup window & Blur Parent window jkusmanto Javascript How-To 0 May 25th, 2007 03:19 AM
adding new listbox object to window opener Vash Javascript 3 October 10th, 2006 02:02 PM
closed parent window when opened child window jaiwin Javascript How-To 0 October 8th, 2006 12:54 PM
Resolution of property names on window object AGS BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 3 August 5th, 2006 11:50 AM
Close Parent window on opening child window pkdev Javascript How-To 8 April 11th, 2004 12:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.