write to iframe in Opera

J

juergen.riemer

Hi all,

I create an IFrame and want to dynamically add content to it in Opera
(8.54) like this:

<html>
<body>
<script>
oPanel = document.createElement("IFRAME");
oPanel.src = "about:blank";
document.body.appendChild(oPanel);
oPanel.addEventListener("load", function(){
var oImage = oPanel.contentDocument.createElement("IMG");
oPanel.contentDocument.body.appendChild(oImage);
}, false);
</script>
</html>
</body>

I get the following error message:

-----
Event thread: load
Error:
name: Error
message: Security violation
-----

I learned about problems Opera has to not apply anti cross domain
policy when dealing with frames. But how to solve this? Any idea?

greetz

mord
 
M

Martin Honnen

I create an IFrame and want to dynamically add content to it in Opera
(8.54) like this:

With Opera 8.5 on Windows I managed that with an enforced delay using
setTimeout e.g.

var iframe = document.createElement('iframe');
iframe.addEventListener(
'load',
function (evt) {
var doc = iframe.contentDocument;
var p = doc.createElement('p');
p.appendChild(doc.createTextNode('Kibology for all.'));
doc.body.appendChild(p);
},
false
);
document.body.appendChild(iframe);
setTimeout(function () {
iframe.contentWindow.location.href = 'dummy.html';
}, 10);

where dummy.html simply has the basic
<htm><head><title></title></head><body></body></html> structure of an
HTML document.
 
J

juergen.riemer

Martin,

Ingenious! Loading the iframe with a dummy which indicates it being
from the same domain, I just had to replace
oPanel.src = "about:blank";
with
oPanel.src = "dummy.html";
to make it work.
It was my ignorance about how browsers would deal with "about:blank"
(same with my other post about relative paths in iframes created with
"about:blank"

thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top