Click here to Skip to main content
15,922,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<a  onclick="window.close();" title="Close" >
      <img src="Close.png" />
  </a>


I Try This Code In My Project ..
IE8 And Some Browsers Support This Code But Fire Fox And Chrome CAN NOT Support This Code.

JavaScript
window.close();


Why Fire Fox And Chrome Can not Run My Code but IE8 , IE8+ And Other Browsers Support That ?

Please Help ME
Best Regards AJ
Posted
Updated 14-Sep-14 23:02pm
v3

By default Firefox don't allow to close tab using JavaScript
It is needed to follow these steps in Firefox

1. Go to address bar and type about:config
2. Go to parameter dom.allow_scripts_to_close_windows
3. Set its value as true

See more here[^]
 
Share this answer
 
Comments
Ali Javani 24-Sep-14 13:30pm    
thanks For Solution
and i have an other Question ...
can i Do this Config in Code with Java Script ?
[no name] 24-Sep-14 13:45pm    
That i am not sure about , since it is the property of browser. It is not possible i guess. I will share with you if i find any answer for it. Thank you
[no name] 24-Sep-14 13:59pm    
You can check here https://support.mozilla.org/en-US/questions/996592
Mozila Says "Scripts may not close windows that were not opened by script."

https://developer.mozilla.org/en-US/docs/Web/API/window.close[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900