'Access Denied' when using javascript to change page location

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a problem when I try to do this on a aspx page..
Is there anything wrong with this approach?


This is the javascript function

<Script Language='JavaScript'>
function OpenLink(Link){
parent.right.document.location=Link;
}</Script>

And I call it like this:

<A HREF=javascript:OpenLink('MyRequests.aspx')></A>

The strange thing about it is that if I use the localhost
address this code works, but if I put in the machine name
as the address to the web page, I get an 'access denied'
on the second line in the javascript function
(parent.right.document.location = Link;)

Appreciate any help!
thanks,
John
 
Hello

What you are trying to do is called cross domain scripting, which means that
a javascript in one html document tries to access objects in another html
document and the other html document comes from a different domain.
(localhost and machine name are considered different domains even though
they are the same machine and same website).

Web browsers are designed to prevent this for security reasons. Imagine a
malicious website reading your hotmail email because you happen to read your
email and browse the malicious site at the same time. This is by design.

So make sure that all documents come from the same domain.

Best regards
Sherif
 
Back
Top