'Blocked a frame with origin "http://localhost:8080" from accessing a frame with origin "http://pentaho5XXX.com"

I've been about 2 days trying to do something that i can't figure out how to do. The thing is that i am customizing Pentaho user console(which is some kind of web app deployed on a tomcat, which has a lot of iframes one inside another).

The html that i am customizing is inside a iframe(Lets call that iframe "A") with a nav horizontal menu, which has another iframe right below(Lets call this iframe "B"). Every single link of the nav and some of the iframe "B" are loaded on the iframe "B", and all the url points to a hosted server with the domain www.pentaho5XXX.com.

I am doing all my test at localhost:8080. My problem is that when i try to access to a variable inside of the Iframe "B"(the iframe where the url are loaded), the Console gives me the following error:

Uncaught SecurityError: Failed to execute 'alert' on 'Window': Blocked a frame with origin "http://localhost:8080" from accessing a frame with origin "http://pentaho5XXX.com" Protocols, domains, and ports must match.

I understand that it's because i am trying to access to the DOM of a url that is hosted in a diferent domain. My problem comes out when i am trying to do it with a localhost:8080 web page and the iframe doesn't load the page(When i put my ip:8080/mypage it frezes and doesn't do anything, and when i put localhost:8080 it loads me a blank page) and the navigator console gives me no errors.

I've checked the same url on a new tab and it works with both links so i dont know why does that happen.

Another thing that i may be doing wrong is that i try to access to the dom variable and change the src of the iframe "B" inside the same iframe("B")

I would be very pleased if someone could help me, but i would appreciate the time you took reading, so thank you in any case.



Solution 1:[1]

what you are trying to do is just impossible because of "the same origin policy", web-navigators don't allow you to access the attributes of an "external iframe", neither its content. the browser might act differently when the server is local like your's but it won't let you access the iframe tag.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Meshredded