0
<script>
window.location.reload();
</script>

The above code makes the Salesforce page to keep in the reload state when I add this visualforce page as a page layout.

I would like to reload the page once or twice after clicking the save button on the page layout.

I have certain javascript code that will work if the page can be refreshed twice automatically

  • 3
    What's the intended objective of refreshing the page multiple times? I have a feeling there's a more appropriate way to do what you're trying to do. – sfdcfox Apr 13 '16 at 18:18
  • @sfdcfox I have certain javascript code that will work if the page can be refreshed twice automatically – DominicSeb Apr 13 '16 at 18:19
  • @DominicSeb.. I would suggest to add the code in the function and then call it . If you write the code inside the script only , it executes every time the page load/refresh.. Thansk – amidstCloud Apr 13 '16 at 18:24
  • 1
    There shouldn't be any code anywhere that refuses to work until the page has been refreshed twice (and if there is, there shouldn't be). Something is amiss, and you should identify why it's not working. Every time a web page is loaded, the JavaScript engine is initialized, meaning that all the work from the previous reload is wiped out. – sfdcfox Apr 13 '16 at 18:26
  • @sfdcfox I would dare say because SFDC doesn't always render changes on the first reload? I never understood why that happens tbh. – Javier García Manzano Jul 4 '18 at 13:16
0

@DominicSeb.. I would suggest to add the code in the function and then call it . If you write the code inside the script only , it executes every time the page load/refresh.. Thansk

  • Could you please show the code as I have created a function – DominicSeb Apr 13 '16 at 19:02
0

@DominicSeb this seems unnecessary but I see only one way you can do this.

  1. add a URL parameter timestoreload=1 and
  2. execute onload JS with conditional block and check if counter timestoreload is <= 2
  3. if true perform reload with value of timestoreload+1
  4. if false then do nothing.

you can have it set to reload any no of times you wish.

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.