1

Good evening,

I have an issue with inserting an iframe or object in a popup created like that:

//Version 1
function fShowPop()
{   
    var oPopup = window.createPopup();

    oPopup.document.body.innerHTML = '<iframe id="ifrmPop" src="<myLink>"></iframe>';

    oPopup.show(15, 150,200, 200, document.body);
}

//Version 2
function fShowPop()
{   
    var oPopup = window.createPopup();

    oPopup.document.body.innerHTML = '<object  data="<myLink>" type="text/html"></object>';

    oPopup.show(15, 150,200, 200, document.body);
}

So the result is a blank square... And the page source is not affected.

<html><body></body></html>

If I use document.write the source is affected but it stay blank.

Thanks beforehand!

UnBoug
  • 167
  • 1
  • 12

2 Answers2

1

There are 2 Possible Problems:

  • The window.createPopup() method is no longer supported. It used to be an Internet-Explorer-only function, but now it's not supported in any browser at all.

  • The iframe has no width or height attributes set, so it'll be zero size. However, modern browsers have a default iframe size of 300 pixels by 150 pixels.

Since the most likely reason is no browser support, check out http://www.quirksmode.org/js/popup.html, which is an alternative.

clickbait
  • 2,818
  • 1
  • 25
  • 61
  • Thank you for your advises! Unfortunatetly window.open, is blocked by the browser.. – UnBoug Jun 12 '15 at 19:28
  • Google Chrome is smart. In Chrome, it will allow window.open only if it's caused by user action. For example, you can click a button to open a pop-up, but the pop-up isn't allowed to open by itself. Firefox also has a similar implementation. – clickbait Jun 12 '15 at 19:31
  • 1
    Unfortunately IE is the only browser supported. I must find a way to bypass the popup blocker... I tried to simulate a button click, but the browser is smarter than me! I can't use jquery and ajax, even the vanilla javascript version of ajax call... I'm very limited on my moves... – UnBoug Jun 15 '15 at 13:07
  • http://stackoverflow.com/questions/9514698/bypass-popup-blocker-on-window-open-when-jquery-event-preventdefault-is-set – clickbait Jun 15 '15 at 18:18
0

Ok I solved it:

//Version 3
function fShowPop()
{   
    var oPopup = window.createPopup();
    oPopup.document.body.innerHTML = '<a target="_blank" href="<mylink>"><img title="" src="../../pics/mypic.gif" border="0"></a>';
    oPopup.show(15, 150,200, 200, document.body);
}

There is a strange behavior with the popup, but at least it show well.

Thank you!

EDIT: finally it does not work...forget about it. Window.open seems the only way to achieve it...

UnBoug
  • 167
  • 1
  • 12