Thursday, December 6, 2012

Standard pop up box in Salesforce using JavaScript

We can make use of alert() in javascript to display the pop in Visualforce page. But there another pop up box which looks pretty good and it is providing by Salesforce.

Below is the code to create a pop up box in Visualforce :

<apex:page >
<script type="text/javascript">
document.body.style.cursor="auto";
var box=new SimpleDialog("Test", true);
box.setTitle("Test Pop up");
box.createDialog();
    box.setContentInnerHTML("<b>Praveen</b><input type=\"button\" value=\"Ok\"  onclick=\"javascript:box.hide();\"/>");
box.show();
</script>
</apex:page>


5 comments:

  1. Hi Praveen Kumar K,

    Really useful code.Thanks for sharing.

    One question- is this, functionality of sfdc or it is custom one?

    Regards,
    Santosh

    ReplyDelete
    Replies
    1. It is the SFDC standard popup box and it works only if the header is true in VF page

      Delete
  2. It is the standard salesforce pop up.. we can use this in VF pages and custom buttons which calls javascript as an action.

    Note : page header should be visible to execute this pop up code.

    ReplyDelete
  3. Page is refreshing once i click on the button to open the popup.

    ReplyDelete
    Replies
    1. There must be some error in the javascript like semi-colon missing or some syntax errors.

      Delete