Close Web Borwser Problem, Need Help!

Hi, I have used top.window.close() to close the browser using a button called “Approved” in my application. But I want this condition to be happened only when user open the document through doclink in the web mail which open the document in a new browser, and when user click the “Approve” button, the document close and return to the web mail.

top.window.close() fulfilled the above condition, but if user directly access the application through web and open the document from the view, then click the "Approved" button, it will pop out the message "The web page you are viewing is trying to close the window. Do you want to close this window?". No matter user choose "yes" or "no", the browser will not close.  

 What I want here is to make the system not to close the browser when user access the system directly through browser (because every page is opened using the same browser) however the document opened through the web mail use a new browser to open the doclink. How to make the system to differentiate between document is access through a new browser (or access through doclink) and document is access directly through the view? 

Can I avoid the web browser message to appear if we are not able to differentiate the the way user accessing the document?

Subject: Close Web Borwser Problem, Need Help !

The pop up message should only appear if the browser window has history.

You should therefore write something to check the top.window.history.length before doing top.window.close().

Good Luck

Jon