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?

  • Have you tried window.location? – Michael Gill Sep 27 '12 at 17:31
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();    
}​
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.