473,587 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

window.close() and Mozilla/Netscape

Hello to everybody,
I'm trying to make a link that closes the browser:

<a href="javascrip t:window.close( )">CLOSE</a>

It works with IE6 but not with Mozilla and Netscape.
Does anybody knows the reason why?
Thanks.

Nov 24 '05 #1
7 22969
VK

signo wrote:
Hello to everybody,
I'm trying to make a link that closes the browser:

<a href="javascrip t:window.close( )">CLOSE</a>

It works with IE6 but not with Mozilla and Netscape.
Does anybody knows the reason why?


Read this newsgroup FAQ:
<http://www.jibbering.c om/faq/#FAQ4_14>

If the current window has been *open via script* on the main page,
then:
<a href="noScript. html" onclick="window .close();">CLOS E</a>
will work on any decent browser.

If the current window did not appear via window.open() then the user
will be prompted first or such request will be disregarded - depending
on browser version and security settings.

Nov 24 '05 #2
VK wrote:
If the current window has been *open via script* on the main page,
then:
<a href="noScript. html" onclick="window .close();">CLOS E</a>
will work on any decent browser.


However, there is exactly no use to provide a "close link" that will only
work if client-side scripting is enabled. Nothing is accomplished by
directing the user to a document that states "we are sorry that the window
could not be closed because client-side scripting is not present", and
telling him how to close the window. Maybe he do not even have one, maybe
he has a tab or something else; anyway, such a description would have to
include procedure on all conceivable UAs which is just not possible.

Such links are better to be generated _via_ scripting so that in the
unlikely event (given proper search engine optimization) someone finds the
"popup" document through a search engine, or in the more likely event that
the document is accessed through a gracefully degrading link, those users
are not bothered with virtually useless links.

<script type="text/javascript">
document.write(
'<a href="#" onclick="window .close(); return false;">CLOSE<\/a>');
</script>
PointedEars
Nov 24 '05 #3
signo wrote :
Hello to everybody,
I'm trying to make a link that closes the browser:

Why do you need to provide a link that closes the browser? Isn't there a
close button in the titlebar to do that? Also, entirely at the disposal
of the user? Isn't that enough? A link should be used to go somewhere
(URL), not to modify the browser interface.
<a href="javascrip t:window.close( )">CLOSE</a>

It works with IE6 but not with Mozilla and Netscape.
Does anybody knows the reason why?


Yes. The default value of dom.allow_scrip ts_to_close_win dows is false.
In other words, by default, the browser refuses to allow script to close
windows, just like that. The user can find its way all by himself to the
titlebar or with Alt+F4 if he wants to close the window. No javascript
needed from content developer. Same thing with the opening of new
windows. Same thing with Back button. Etc... The content developer never
needs to code and to duplicate the basic and normal functionality of
browsers.

Gérard
--
remove blah to email me
Nov 24 '05 #4
>Why do you need to provide a link that closes the browser?

I'm making a CD that is containing some manuals.
The CD is starting in a "autorun way" and the interface is made in
html; anyway I gave up with the close button and I took him away.

Thanks for every suggestion.

Massimo

Nov 24 '05 #5
On 2005-11-24, signo <ma************ **@libero.it> wrote:
Hello to everybody,
I'm trying to make a link that closes the browser:

<a href="javascrip t:window.close( )">CLOSE</a>

It works with IE6 but not with Mozilla and Netscape.
Does anybody knows the reason why?
Thanks.


security.


--

Bye.
Jasen
Nov 26 '05 #6
jgnagaraju
1 New Member
In Mozilla by default the "dom.allow_scri pts_to_close_wi ndows" value which controls the Java Script close window is set to "false". In order to fix this issue change this value to "true"

1. Location of the File:
C:\Program Files\Mozilla Firefox\grepref s\all.js

change "dom.allow_scri pts_to_close_wi ndows" from "false" to "true"

Example:
Default value
pref("dom.allow _scripts_to_clo se_windows", false);

Change it to
pref("dom.allow _scripts_to_clo se_windows", true);

2.Close Mozilla browser

3.Try accessing HTML page which has window.close() code snippet... :)
Mar 8 '06 #7
rakesh_halder
1 New Member
hope this script will help u to close the window.

The first step is to fool the browser into thinking that it was opened with a script…

window.open('', '_parent','');

This opens a new page, (non-existent), into a target frame/window, (_parent which of course is the window in which the script is executed, so replacing itself), and defines parameters such as window size etc, (in this case none are defined as none are needed). Now that the browser thinks a script opened a page we can quickly close it in the standard way…

window.close();

And there you have it - I told you it was simple! In case you didn’t follow that, here is the complete solution in two easy steps:

1. Copy/paste the following code to the head of your page…

<script language="javas cript" type="text/javascript">

function closeWindow() {

window.open('', '_parent','');

window.close();

}

</script>

2. Set your link like this:

<a href="javascrip t:closeWindow() ;">Close Window</a>

And there you have it - A problem that it seemed, (according to my trying to find a solution before coming up with this one anyway), to have baffled everyone else.
May 22 '06 #8

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

Similar topics

4
22062
by: John H. | last post by:
Hello I have some trouble in closing a window, Here is the problem: I develop a asp.net website use client side valiation <asp:CustomValidator id="CustomValidator1" ControlToValidate="Text1" ClientValidationFunction="BasicSearchValidation" OnServerValidate="ServerValidation"
9
6267
by: ScooterMX | last post by:
I have a <a href="javascript:top.window.close()"><img src="exit.gif"></a> tag on my page that closes itself when you click on it. What I NEED is for it to put up a confirmation message that simply asks "This will end your session and close the window", then offers a cancel or ok button. Clicking on ok closes both the page it was on, and the...
10
37982
by: Shang Wenbin | last post by:
Hi, When I want to close the current window using window.close() in IE6.0, there will be a confirm box that: The web page you are viewing is trying to close the window. Do you want to close this window? I have to click yes to close the window. How can I close the current window directly without this dialog box? Thank you.
22
130084
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the document and closes it with the following code: <body onload="window.print(); window.close();"> This works correctly (or at least the way I expect...
37
6306
by: Jan Tovgaard | last post by:
Hey everyone:) We have a critical problem, which I can see that other people also has ran into. In Internet Explorer 7 it is no longer possible to do a window.close after opening a window, without getting a alert message that ask if u want to close the window. This did NOT happen in Internet Explorer 6, Mozilla firefox or other browsers.
7
5809
by: Toccoa | last post by:
After considerable googling - I mean searching with Google(r) - I could not find javascript on a button or <a href=... to close a window in the latest versions of IE and FireFox. There seemed to be two techniques for earlier versions. But the window.opener='' ;window.close(); and the window.open('','_parent','') ;window.close(); ...
5
34358
by: jimmy | last post by:
Hi all, I want to capture the event when the browser's close button is clicked in an html page. I tried using the event.ClientX and event.ClientY property in the body unload event, and this helps to recognise whether the close button is clicked( also differentiates whethet refresh was clicked). The problem arises whenever i try to close...
0
1274
by: Riteshkk2000 | last post by:
Document.forms.form1.Submit() not working in Mozilla/Netscape Please help me on this; If some one know the alternate solution for that I can not provide one button and cllick to submit the page. thanks in advance
1
1323
by: samduniya | last post by:
Hi All I have the following source code <HEAD> <iframe name = "myFrameName" src = " " id="myFrame" style = hidden width = 0 height = 0 frameborder = 0></iframe> <script Language="JavaScript"> var str = "<%=session.getAttribute( "userprivilege" )%>"; var str1 = "<%=session.getAttribute( "grpQuery" )%>"; ...
0
8340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5713
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.