3

I am including a frame in my html document. What I want to do is to change some text in the frame. The frame is not hosted on my website. I have a logic like this:

  1. let the frame to load
  2. Use jQuery document.ready function
  3. When the document is completely loaded,I will change the element by document.getelementbyId("id of element")

Unfortunately this is not working. I had Googled a lot but didn't find any suitable answer. Can anyone assist me?

Here is the frame:

<iframe src="http://www.traffic-zombie.com/en/members/referral?campaignID=1190&backgroundColor=%23ffffff&textColor=%23000000" width="650" height="1000" frameborder="0" style="border: 1px solid #ffffff;"></iframe>

Let say I want to change the word "referral" in the frame; here is my script:

<script type="text/javascript">

$(document).ready(function() {      
    
    var c=document.getElementById('zom-status').innerHTML;
    alert(c);
});
    
</script>

Any help will be appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
require_once
  • 1,995
  • 3
  • 21
  • 29
  • 1
    You cannot do this because of security restrictions. Here is what I found on the net as workarounds: http://www.cakemail.com/the-iframe-cross-domain-policy-problem/ http://stackoverflow.com/questions/6732054/cross-domain-restriction-and-limitations-from-an-iframe – Ivancho Mar 01 '12 at 14:23
  • http://stackoverflow.com/questions/3083112/jquery-cross-domain-iframe-scripting – Fresheyeball Mar 02 '12 at 04:43
  • possible duplicate of [Cross domain iframe issue](http://stackoverflow.com/questions/9393532/cross-domain-iframe-issue) – zwol Mar 13 '12 at 23:07

1 Answers1

0

It is generally not possible. jQuery cross domain iframe scripting

You may want to consider grabbing the html for that iframe and then injecting it into the page, at least that way you will have total control. Take a look here to learn about that technique, I believe its far more likely to bear fruit:

http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/

Community
  • 1
  • 1
Fresheyeball
  • 29,567
  • 20
  • 102
  • 164