0

This question is continuation of this question. I use the following code to append the dynamic <iframe> to the document.

var _hf_iFrame = document.createElement("iframe");
_hf_iFrame.setAttribute("id", "_hf_iFrame");
_hf_iFrame.setAttribute("name", "_hf_iFrame");
_hf_iFrame.setAttribute("allow-transparency", true);
_hf_iFrame.setAttribute("style", "height: 354px; width: 445px; border: 0; top: 23%; position: fixed; left:0; overflow: show; background:transparent;");
document.body.appendChild(_hf_iFrame);
_hf_iFrame.setAttribute("src", "javascript:false");

var myContent = '<!DOCTYPE html>'
+ '<html><head><title>Helpflip</title><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script><script type="text/javascript" src="http://somedomain.com/js/core.js"></script></head>'
+ '<body style="margin: 0px;"></body></html>';

_hf_iFrame.contentWindow.document.open('text/html', 'replace');
_hf_iFrame.contentWindow.document.write(myContent);
_hf_iFrame.contentWindow.document.close();

When the <iframe> has loaded, I am trying to animate it using the following code

$('#_hf_iFrame', top.document).animate({
      'margin-left': '-400px'
   }, 300).animate({
      'margin-left': '-380px'
   }, 150).animate({
      'margin-left': '-393px'
}, 100);

This works fine on Firefox, Chrome and on Safari. IE 9 throws Access Denied on line $('#_hf_iFrame', top.document)

Does the problem of cross domain still apply?

Thanks in advance.

Community
  • 1
  • 1
Libin TK
  • 1,477
  • 2
  • 25
  • 46
  • Did you try leaving out the `.src` line (so no `.src` on the iframe) as it is not required. IE may be thinking that you're trying to do a cross-domain access. – jfriend00 Oct 18 '12 at 04:39
  • Hi Libin, Just being curious why you are writing HTML of IFRAME in JavaScript. Wouldn't be better if you make a static HTML page and give that URL to IFRAME. And Problem of CrossDomain can exist as the SRC DOMAIN of IFRAME will not be same as parent page. – Purusottam Kaushik Oct 18 '12 at 04:41
  • @jfriend00 Yes... but with no success... – Libin TK Oct 18 '12 at 04:43
  • @PurusottamKaushik Hey, I had tried that but then IE, FF and chrome threw "Access Denied" due to the Same Origin Policy and I was not able to animate or even access the ` – Libin TK Oct 18 '12 at 04:46
  • Are you running the HTML page off your own hard disk? There can be cross-origin issues when running off the local drive instead of off a real web server. – jfriend00 Oct 18 '12 at 04:58
  • @jfriend00 tried that too.. even I am able to set `document.domain` to match parent document on all browsers. So the Cross origin will not be an issue, I guess.. – Libin TK Oct 18 '12 at 05:02

0 Answers0