'Access Denied' when using javascript to change page location

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
 
S

Sherif ElMetainy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top