1

i am using Facebook graph API to invite Facebook friends to my codeigniter application , i want to fire a click event inside an element of iframe , but it is not firing , my code is

        $("iframe").contents().find('input[name="login"]').live('mouseover',function(){
                          alert("log in");
         });

alert is not shown , no errors in firebug .

but if i do this

    $("iframe").live('mouseover',function(){
                      alert("log in");
     });

this works and give the alert .

but if i try to get html inside iframe

$("iframe").live('mouseover',function() {          
   alert($('.fb_ltr').contents().find('.request').html());                      
});


it gives an error in firebug 


Permission denied to access property 'ownerDocument'
[Break On This Error] shift(),i.sort());if(!!e&&!f.event.cus...is).get();f(e[h])[b](j),d=d.concat(j

how to use elements inside iframe , i saw similar questions , but could not get a help . please help , thanks ..............................

Lee
  • 13,462
  • 1
  • 32
  • 45
Kanishka Panamaldeniya
  • 17,302
  • 31
  • 123
  • 193

2 Answers2

3

You are unable to access/manipulate any content via iframe if it's from a different domain.

jQuery/JavaScript: accessing contents of an iframe

Community
  • 1
  • 1
Jason
  • 848
  • 6
  • 17
1

The Iframe is treated as a single element.

Thats why your code:

$("iframe").live('mouseover',function(){}); 

works but accessing its element won't

see this jQuery - Trying to select element from iFrame (point and click)

Community
  • 1
  • 1
Broncha
  • 3,794
  • 1
  • 24
  • 34