[ 13 posts ] Go to page Previous1, 2

Mark

  • Offline
  • Profile
Tags:

Re: Using yui in an iframe

Post Posted: Mon Oct 03, 2011 6:20 pm
+0-
Hi Michael,

Unfortunately that site's gone the way of the Dodo. Here's a snippet that may help you.

Code:
<iframe src="local.html" id="frame"></iframe>
<script type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/3.1.1/build/yui/yui-min.js"></script>
<script type="text/javascript">
YUI().use("node", function(Y) {
   
    var frame = Y.one('#frame'),
        win = Y.Node.getDOMNode(frame.get('contentWindow')),
        doc = win.document;

    YUI({ win: win, doc: doc }).use('node', function(innerY) {
        innerY.one('body').setStyles({
            backgroundColor: 'red',
            color: 'white'
        }).append('<p>YUI3 was loaded!</p>');

    });

});
</script>

Dimitar Bonev

  • Joined: Mon Aug 22, 2011 2:58 am
  • Posts: 2
  • Offline
  • Profile

Re: Using yui in an iframe

Post Posted: Tue Dec 06, 2011 3:23 am
+0-
Hello,

I've been trying to use YUI instance with an iframe following the method described in this topic. It works in Chrome 15 and Firefox 7 and fails in IE7 and IE8. Here is part of the code:

Code:
...
var printFrameNode = A.Node.create('<iframe id="print_frame" width="640" height="0" frameborder="0" src="about:blank"></iframe>');
           
var body = A.one('body');

body.append(printFrameNode);

var frame = A.Node.getDOMNode(A.one('#print_frame'));
           
var printWin = frame.contentWindow;

YUI({
   win: printWin,
   doc: printWin.document
}).use('node', function(F) {
});
...


IE8 console prints that the problem is in dom-base.js file and I found out that the variable documentElement is null after this line of code:

Code:
var documentElement = Y.config.doc.documentElement


This variable is checked for various properties in the Y.mix method that follows the initialization of the variable. I tried to create the iframe node with html element inside:

Code:
A.Node.create('<iframe id="print_frame" width="640" height="0" frameborder="0" src="about:blank"><!DOCTYPE html><html><head><title></title></head><body></body></html></iframe>');


But still the same error occurs.

Do you have any idea for this issue? Is this a bug in YUI library?

Juan Ignacio Dopazo

YUI Contributor

  • Username: jdopazo
  • Joined: Fri Oct 02, 2009 5:39 am
  • Posts: 619
  • Location: Buenos Aires, Argentina
  • Twitter: juandopazo
  • GitHub: juandopazo
  • Gists: juandopazo
  • Offline
  • Profile

Re: Using yui in an iframe

Post Posted: Tue Dec 06, 2011 4:42 am
+0-
No, it's just that IE takes a little time to create the document structure in an iframe. You should give the Frame class a try.
  [ 13 posts ] Go to page Previous1, 2
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
cron