• Sukhabogi Niharika
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi all,
Right now I am creating a pop on detail page button.Everything is fine except it's height can anyone help me on how to create a dynamic iframe using javascript?

Here is my code.
(function() {
    var width = 700;
    var height = 515;
    var title = "Dialog title here";

    var box = new SimpleDialog("salesforce" + Math.random(), true);
    box.setTitle(title);
    box.displayX = true;
    box.isMovable = false;
    box.createDialog();
    box.setWidth(width);
    // set your html content here
    box.setContentInnerHTML(
      '<iframe src="/apex/toastmessage?Id={!Account.Id}" style="border:none;" width="100%" height="'+ (height - 30)+'px" />'
    );
    //set the height of the modal
     box.dialog.children[1].style.height = height + 'px';
    box.show();

    //if displayX is set to true, then override standard close event by this code
    box.dialog.getElementsByClassName('dialogClose')[0].onclick = function() {
      box.hide();
      // you can add code to reload the page or redirect to another page 
    };
    //optional : add this to close the modal onclick of the overlay background
    box.background.addEventListener('click', function() {
      box.hide();
    });
    
    // if you want to be able to close the modal from the Visualforce page
    window.addEventListener('message', function(event){
      if (event.data === 'close'){
        box.hide();
      }
    });
})();

Thanks in advance