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?
Attribution to: Devendra
Possible Suggestion/Solution #1
1) This is really isn't a salesforce question but instead a javascript one.
2) Seems like a weird button. Users may get upset at this button's confusing behavior.
However, something like this should work for you.
if(window.history.length > 2) {
window.history.back();
} else {
window.close();
}
Attribution to: Phil Rymek
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/1717