0

I want to replace the URLs that are appearing in the Facebook Comment Box on my site, because my Domain Name has changed since those comments with URLs were posted.

For example, Change all:

Site1.com => site2.com

Site1.com => Site2.com

I made a code that works in general on my site, to replace text stings:

$("div").each(function (i) {
$(this).html($(this).html().replace('site1.com','site2.com'));
});

The problem is that the Facebook Comments box is inside an iFrame.

So can someone help me edit this code to target the text inside the iFrame?

I guess it should not be too hard, but I'm a noob at JavaScript/jQuery. Sorry.

Also, I wonder if because of the way the Comment box is loading (not instantly, looks like Ajax), it is affecting the timing at which my script can modify the text in the Facebook Comment boxes.

Please let me know if you understand what I mean.

Maybe I need to do something to activate the JS at the right moment? I try to load it after the <body> at the moment.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
  • Thanks Jeff and Brandon. It seems that I won't be able to do as I wish because of the "Same Origin Policy". Yes the iframe is not in the same domain as my website. There is no other possible ways of achieving what I am trying to do then? Like something other than Javascript. Yes I to already have a Permanent Domain Redirect from my old Domain to the new one, but I still dislike seeing the old Domain appear there in my older comments. (Which are rated at the Top) – Andrew Davis Mar 18 '12 at 06:19
  • Try looking at http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy – Jeff Lamb Apr 10 '12 at 16:20

2 Answers2

0

If the iframe is not within the same domain, you should be getting 'permission denied' errors. This is blocked by most web browsers. See Same Origin Policy for more details.

Jeff Lamb
  • 5,755
  • 4
  • 37
  • 54
0

While you cannot alter the links themselves due to the Same Origin Policy, you can set up a rule for redirecting pages on your old domain to their counterpart pages on your new domain.

Fisch
  • 3,775
  • 1
  • 27
  • 38