Open Pop up window as a visualforce on Click on Custom Button

Requirement:  Create a Custom Button on detail page, when user click on this a visualforce page will open as like popup.

Solution

Note: Create a visualforce Page

Step 1 : Download the zip file from given below link

https://docs.google.com/uc?export=download&id=0B36Q9KSdCf-6N0wtV2tUUDRCTmM

Step 2 : upload this file in static resource 

Static resource Name:  jQueryForPopup.

Step  3: Create a custom button, behaviour (Execute JavaScript)


Java script code for  custom button:

{!REQUIRESCRIPT('/soap/ajax/26.0/connection.js')}
{!REQUIRESCRIPT('/js/functions.js')}
{!REQUIRESCRIPT('/resource/jQueryForPopup/jQuery/jquery-1.8.2.min.js')}
{!REQUIRESCRIPT('/resource/jQueryForPopup/jQuery/ui/jquery-ui-1.9.1.custom.min.js')}
{!REQUIRESCRIPT('/resource/jQueryForPopup/jQuery/postmessage/jquery.ba-postmessage.js')}
{!REQUIRESCRIPT('/resource/jQueryForPopup/jQuery/bbq/jquery.ba-bbq.min.js')}
requireCssFile('/resource/jQueryForPopup/jQuery/ui/css/ui-lightness/jquery-ui-1.9.1.custom.min.css');
function requireCssFile(filename)
{
var fileref = document.createElement('link');
fileref.setAttribute('rel', 'stylesheet');
fileref.setAttribute('type', 'text/css');
fileref.setAttribute('href', filename);
document.getElementsByTagName('head')[0].appendChild(fileref);
}
var j$ = jQuery.noConflict();
var iframe_url = '{!URLFOR("/apex/VisualForcePageName")}';
var child_domain = iframe_url.substring(0, iframe_url.indexOf('/', 9));
var parent_domain = window.location.protocol + '//' + window.location.host;
var j$modalDialog = j$('<div id="opppopup"></div>')
.html('<iframe id="iframeContentId" src="' + iframe_url + '" frameborder="0" height="100%" width="100%" marginheight="0" marginwidth="0" scrolling="no" />')
.dialog({
autoOpen: false,
title: 'My Visualforce Page',
resizable: true,
width: 900,
height: 400,
autoResize: true,
modal: true,
draggable: true
});

j$modalDialog.dialog('open');


Step 4: Go on Detail page edit layout drag the custom button on Detail page then click on button

your visualforce page will open as like popup.

Thanks
Sumit Shukla
sumitshukla.mca@gmail.com
skype id : shuklasumit1

Comments

Popular posts from this blog

Salesforce Spring 16 Release Exam (Maintenance Exam Q&A) for Developer 201 Admin

Show Hyper Link On Add Error in Salesforce Trigger

Show the Success Message before Redirecting the Detail page on Visualforce Page