0

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?

1
  • Have you tried window.location? Sep 27, 2012 at 17:31

1 Answer 1

3

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();    
}​

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .