iFrame access denied remote domain

How do i send a JavaScript function to an iframe with external content loaded,

eg

onclick="getElementByID('myiframe').src='fun();'"

is there a way with ajax, i think XMLHttpRequest can help me.

Answers


You can't, it's a security feature


everything must be on the same domain. or you will need to setup a proxy


As stated earlier you cannot do this because of the builtin security model of the browsers.

However, if the two sites are hosted on the same subdomain, for example appA.company.com and appB.company.com, you can get around it using domain relaxation. All you have to do is to set the document.domain in both pages to company.com. See http://www.tomhoppe.com/index.php/2008/03/cross-sub-domain-javascript-ajax-iframe-etc/ for more information


Need Your Help

HashMap wrong values for keys

java hashmap key key-value

I am kinda new to Java, and I am trying to write a function that maps all element indexes from an ArrayList into a HashMap, so I can easily see the indexes of duplicate elements.

403 Error on Stylesheet - Rasberry Pi Webserver

css linux web webserver raspberry-pi

I keep seeing a 403 error for my stylesheet which is hosted on my Rasberry Pi (webserver). I ran ls -al and this is the result: