473,503 Members | 1,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

window.close() not working

60 New Member
Hi

In my php page i'm having a close image button. Onclick , i'm trying to close the
current browser window. It is not working.
<img src = image_close.jpg onClick="window.close()">

Pls post your replies

Thanks in advance
somaskarthic
Aug 28 '06 #1
5 4541
vssp
268 Contributor
Try this

<img src = image_close.jpg onClick="javascript:window.close()">
Aug 28 '06 #2
Banfa
9,065 Recognized Expert Moderator Expert
window.close()

only works if you opened then window in the first place, you can not close a window opened by the user.
Aug 28 '06 #3
rkagrawal
13 New Member
Hi

In my php page i'm having a close image button. Onclick , i'm trying to close the
current browser window. It is not working.
<img src = image_close.jpg onClick="window.close()">

Pls post your replies

Thanks in advance
somaskarthic
If you are echoing it , make sure that echo has echo ' text '; and not echo " text ";

If the close doesnt works , try javascript:exit()

Kind Regards,
Rahul Agrawal
Web2003 Corporation
Sep 4 '06 #4
vssp
268 Contributor
hai can you please send your code

Thanks
Vssp
Sep 4 '06 #5
BillC
1 New Member
This might help anyone trying to add a "window.close" button to an echoed page (the usual javascript doesn't work with a php echo)... note the single quotes for the echo...

echo '<div id="myDiv">
<p>Bit of content etc. etc.</p>
<script language="javascript" type="text/javascript">
function closeWindow() {window.open("","_parent","");
window.close();}</script>
<input type="button" onclick="closeWindow();" value="Close Window" title="Close window">
</div>';

hope it helps... not tried it in all browsers yet!
Dec 16 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
5145
by: J P Singh | last post by:
Hi Guys Wonder if someone can help me with this. I have a form where a user clicks a button which gives them a pop up windows to allow them to add the data. The user adds the data and click...
3
5163
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same...
9
4970
by: Justin Koivisto | last post by:
Is there a way to create an alert-like message box that uses a custom image? Basically, I want to replace the default ! image with something else. -- Justin Koivisto - spam@koivi.com PHP...
3
2344
by: Martin | last post by:
Hi, this is probably a very basic question but I'm not a javascript expert! Sure you get this asked often! Did some research but can't get it working. I'm thankful for any help! Thanks! ...
3
1955
by: Asit | last post by:
<META HTTP-EQUIV="expires" content="0"> <META HTTP-EQUIV="pragma" content="no-cache"> <html> <head> <title>Fidelity NetBenefits</title> </head> <body BGCOLOR="#ffffff"> <script...
2
2280
by: RWC | last post by:
Hello, I am new to JavaScript but until now, have felt my way along fairly successfully. I have a page showing an image to the user. I use window.open to open a separate page, listing a bunch...
7
2584
by: Drew Berkemeyer | last post by:
Hello, We have an application that we have written using ASP.NET. On one of our pages we open a popup window using javascript. The popup window has a save and a cancel button. Both of them are...
14
2756
by: Paul | last post by:
Hi I have 2 functions in java script, one opens a second window-this works, the other is supposed to close this second window, does not seem to be working. Just wondering if anyone had any ideas....
5
3069
by: lindanr | last post by:
In ASP.NET 2005 I have an onblur="window.close()" javascript event in the <body> tag. When I click on the window's scrollbar, the window closes. The same code works fine in ASP.NET 2003. Any...
3
4094
by: Laurahn | last post by:
The function javascript:window.close() is not working in firefox. how do i close browser window in firefox.
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
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...
1
6993
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...
0
7462
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...
0
5579
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,...
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
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...

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.