mehdi mehdi - 2 years ago 144
PHP Question

remote call javascript function from another site

I have a upload script in another host and after remote file upload with

I call a function like this :

echo '<script language="javascript" type="text/javascript">'.$result.' , \'res2\' , uploaded , dkey);</script>';

function in the main page should run and do some thing (show pictures and ...)
but I get Permission denied error

Error: Permission denied to access property "stopUpload"

tip : Imagine I have
function in
and I call send file with ajax to upload in my another Host page called
I have a
function in pageB which should run on pageA after upload complete but face to above error ...

Can I call javascript function in another page remotely?


Answer Source

You are probably violating Same Origin Policy.

An Iframe can access parent window content only if they both belong to same origin. An origin consists of Protocol (http/https), domain name( and port(default 80). If any of these are different then sites are considered from different origins. If you are able to modify content of both the sites then you can manually set the After that you won't get the error.


Both the sites should at least have super domain in common for manual domain setting to work.

For example, and can never be compatible since their super domains are different.

However and can be compatible as they have super domain in common.

They both would have to declare in a script tag.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download