kamal salam
kamal salam

Reputation: 17

How to Change All Links inside iframe with javascript

I want to change all links of my site. Suppose a link given by .Example http://www.google.com/ changes to http://www.example.com/?redirect=http://www.google.com/

I use this function and it works but the links inside the iframe don't change

 window.onload = function() {
      var anchors = document.getElementsByTagName("a");

for (var i = 0; i < anchors.length; i++) {
    anchors[i].href = "http://www.example.com/?redirect=" + anchors[i].href
}
}

I want to change the links inside iframe too.

Upvotes: 0

Views: 520

Answers (1)

Neodan
Neodan

Reputation: 5252

You can't access to the content in iframe if it loads a content from another domain.

Upvotes: 1

Related Questions