Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
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 January 9th, 2012, 12:47 PM
Registered User
 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Close Window with Javascript

Hello Everyone!

I really need some help with this matter. I work with an aplication that's got a "viewer" for the pages or activities that I make. So whatever I do is oppened through this viewer.

The viewer gets an ID (which I don't know what will be). So I want to create a button that will close the window of the viewer. I get the ID of the window first:

var itsMe
function whoAreYou(){
itsMe = window.name
}

and with the name of the window, I call this function that is supposed to close the window:

function closeWindow(){
Windows.close(itsMe)
}

but it doesn't work! ;-(

Can somebody help me, please?!

Is that the correct syntax?

Thanks!
 
Old January 9th, 2012, 12:56 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Unless something has changed very recently the code to close a window is:
Code:
window.close();
Note that, in modern browsers, this only works if you have opened the window via script, it DOESN'T work on windows opened by the user in a normal fashion.
__________________
Joe
http://joe.fawcett.name/
 
Old January 9th, 2012, 01:47 PM
Registered User
 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well the window has a close button that does this:

onclick="Windows.close("window_1326126077465", event)"

so I wanto to have a button on my app that does the same thing. But the id "window_132612608..." is generated dynamically

Last edited by mario11; January 9th, 2012 at 01:55 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to close window using javascript in firefox 2. ssfirstbpo Javascript 0 June 29th, 2007 12:04 PM
How to close window using javascript in firefox 2. ssfirstbpo Javascript How-To 0 June 29th, 2007 10:58 AM
How To Close firefox Window through javascript jitendersingal ASP.NET 1.0 and 1.1 Basics 1 February 13th, 2006 07:36 PM
How To Close firefox Window through javascript jitendersingal BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 February 10th, 2006 05:43 AM
How do i close pop-up window?: window.close () Burton HTML Code Clinic 2 September 8th, 2003 05:40 AM





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