Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > 'Access Denied' when using javascript to change page location

Reply
Thread Tools

'Access Denied' when using javascript to change page location

 
 
Guest
Posts: n/a
 
      11-07-2003
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
 
Reply With Quote
 
 
 
 
Sherif ElMetainy
Guest
Posts: n/a
 
      11-08-2003
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

<(E-Mail Removed)> wrote in message
news:00f301c3a567$106058b0$(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change of Page Title when using location.href Anees Javascript 0 09-10-2007 03:43 PM
Location, location, location =?Utf-8?B?VHJhY2V5?= Wireless Networking 2 02-17-2007 08:37 PM
How to trick a page into running at a location different from it'sphysical location? Luke Dalessandro ASP .Net 0 01-15-2006 05:59 AM
output text in control location; calling control javascript from page javascript Lisa Calla ASP .Net Building Controls 0 11-09-2004 02:17 AM
Using window.location to change content on a page Ben Javascript 0 02-10-2004 01:26 AM



Advertisments