Jacques Blom
Jacques Blom

Reputation: 1822

iFrame in a Safari Extension "Popover"

I have a Chrome and Firefox extension, and I am making the same one for Safari.

These plugins all have a popup. In other words, an icon you click on and a page opens up. My Chrome extension popup opens an HTML page in te plugin folder with an iFrame. The FF extension links directly to the PHP page on the server for the popup.

I need to do with Safari what I have done with Chrome. I need to make a local HTML page which has an iFrame to the page on the server. This works in chrome, but the iFrame in Safari is just blank.

Thanks for any help...

Upvotes: 3

Views: 2197

Answers (1)

Luigi van der Pal
Luigi van der Pal

Reputation: 507

Apple doesn't allow iFrames to be loaded within the popover... but! You can do XMLhttpRequest to any domain (say what now?). Yes XMLhttpRequest to ANY domain. Example:

I use this for my selectors (because I didn't want to load jQuery or Mootools in extension):

function $(element) {
    return document.getElementById(element);
}

And just do a XMLhttpRequest like so:

http = new XMLHttpRequest();
http.open('get', 'http://yoursitehere.com/extension/');
http.onreadystatechange = function () {
    $('target-div-id').innerHTML = http.responseText;
}

In this way you can fill the target div with the HTML.

Upvotes: 4

Related Questions