I am creating a Cancel button for force.com site page. This page is a part of a managed package.
I am looking for javascript for this button which can work in two different way. It means, if any user directly opening this page then after clicking on Cancel button close this window. If user is visiting this page after navigating to some other page then on click of Cancel navigate user to previous page( and not to close window this time).
I am checking document.referrer property to check previous loaded page. But seems to be it is not working.
Any ideas?