function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mhlangano KhumaloMhlangano Khumalo 

How to generate a pop up window on a visualforce page automatically when a user opens a page

When the user clicks link on his email it opens up a site/ VF page & on that first page I want the pop to show immediatly without the user clicking a button. The popup works but the problem is you have to click the button first before it shows.

I got the code from here http://www.salesforcegeneral.com/salesforce-modal-dialog-box/
Best Answer chosen by Mhlangano Khumalo
Andreas MeyerAndreas Meyer
Hi,

why so complicated. Just do it by using JavaScript only:
 
<script type="text/javascript">
window.onload = function() {
   window.open('http://www.google.com','google',' menubar=0, resizable=0,dependent=0,status=0,width=300,height=200,left=10,top=10')
}
</script>
the example opens the www.google.com site.

If you really need a modal dialog, use jquery ui "dialog" instead:
http://jqueryui.com/dialog/


Best,
Andreas
 

All Answers

Purnima JothikrishnanPurnima Jothikrishnan
 You can try calling the "showPopup" action in the apex:page tag, that will execute an action method on the controller before anything is rendered. 
This is how it should be done
<apex: page action="{!showPopoup}">.
This will show the popup on load

 
Andreas MeyerAndreas Meyer
Hi,

why so complicated. Just do it by using JavaScript only:
 
<script type="text/javascript">
window.onload = function() {
   window.open('http://www.google.com','google',' menubar=0, resizable=0,dependent=0,status=0,width=300,height=200,left=10,top=10')
}
</script>
the example opens the www.google.com site.

If you really need a modal dialog, use jquery ui "dialog" instead:
http://jqueryui.com/dialog/


Best,
Andreas
 
This was selected as the best answer
Mhlangano KhumaloMhlangano Khumalo
Thank you all so much!  I figured it out thanks to https://sifatkabir.wordpress.com/2014/03/05/simple-jquery-popup-on-page-load/