By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,105 Members | 2,620 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,105 IT Pros & Developers. It's quick & easy.

'Access Denied' when using javascript to change page location

P: n/a
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
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

<an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
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

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.