[SalesForce] Can i embed a iframe into the alert box in visualforce

I have requirement in which on a certain condition i have to show an alert box in which i will have a link and a button. On click of the link i have to do some logic and do some DML operations. What i want to do is that i want to show a custom visualforce page having the link and button and show that page in a iframe in the alert box.
Is this possible or i have to look other way around. Also is there anyway i can i can do this by jquery.

Best Answer

Here is what you can do Create a custom button and fill in the details and in "Behavior Section" choose "Execute JavaScript" and for "Content Source" choose "OnClick JavaScript",and in the code section paste the following code

 
{!REQUIRESCRIPT("https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js")}
    function showSimpleDialog(){
   var sd = new SimpleDialog("Test"+Dialogs.getNextId(), true);
sd.setTitle("Simple Dialog");
sd.createDialog();
window.parent.sd = sd; sd.setWidth("50%"); //Specify the iFrame and give URL of VF page sd.setContentInnerHTML("");

if ($(sd.dialog).find('#InlineEditDialogX').size() == 0) { var close = $("<a id='InlineEditDialogX' title='Close' tabindex='0' href='javascript:void(0)' class='dialogClose'>Close</a>"); close.mouseover(function() { this.className = 'dialogCloseOn'; }).mouseout(function() { this.className = 'dialogClose'; }).click(function() { // finally our on click handler which closes the dialog sd.hide(); }); // insert the new generated close button before the h2 tag so it'll show up on the top right corner close.insertBefore($(sd.dialog).find('.topLeft h2')); } sd.show(); } showSimpleDialog();

This will bring up a modal where you can display your visual force page through iFrame and further through controller you can do all the DML operations.

Related Topic