Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > write to iframe in Opera

Reply
Thread Tools

write to iframe in Opera

 
 
juergen.riemer@chello.at
Guest
Posts: n/a
 
      04-16-2006
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      04-16-2006


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> 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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
juergen.riemer@chello.at
Guest
Posts: n/a
 
      04-16-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
iframe in ie & ff & Chrome & Opera Řyvind Granberg HTML 5 12-06-2008 01:03 AM
How to access variables in an iframe?(Opera,JavaScript) cx HTML 1 08-10-2007 01:56 PM
Comparisons of IE, Opera and Firefox on DOM (Javascript/CSS) support(Opera wins) Bob HTML 24 05-21-2006 05:31 PM
Opera 7.53 vs Opera 6.0 ? Hockey Buff Computer Support 3 08-17-2004 08:53 PM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments