Hello,
I create a new iframe, append it to body, and then try to get its 'document' variable, like this:
var $iframe = $( "<iframe name='my-frame'>" );
$iframe.appendTo( $("body") );
var doc = null;
if($.browser.msie){
doc = window.frames["my-frame"].document; // 'access denied' in IE
} else {
doc = $iframe[0].contentWindow.document;
}
doc.close();
This works fine standalone, but once I try to do it from within a jQuery plugin, IE gives me 'Access is denied'.
(function($) {
$.fn.jqprint = function (options) {
// the above code fails in IE with above error when inserted here
}
})(jQuery);
The weird thing is both ways work in IE on their own, browser check was inserted for debugging.
I'm guessing it's some sort of a scope problem, with 'document' not being accessible from within an anonymous function or something like this. Any pointers?