'Access Denied' when using javascript to change page location

Discussion in 'ASP .Net' started by Guest, Nov 7, 2003.

  1. Guest

    Guest 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
    Guest, Nov 7, 2003
    #1
    1. Advertising

  2. 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

    <> wrote in message
    news:00f301c3a567$106058b0$...
    > 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
    Sherif ElMetainy, Nov 8, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Curt_C [MVP]
    Replies:
    4
    Views:
    432
    Murat Tunaboylu
    Jan 15, 2004
  2. =?Utf-8?B?RU5JWklO?=

    Access denied using location.reload function

    =?Utf-8?B?RU5JWklO?=, Sep 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,773
    =?Utf-8?B?RU5JWklO?=
    Oct 1, 2004
  3. Oliver
    Replies:
    0
    Views:
    124
    Oliver
    Sep 14, 2004
  4. Aaron

    Access denied for location?

    Aaron, Feb 1, 2004, in forum: Javascript
    Replies:
    4
    Views:
    86
    Richard Formby
    Feb 1, 2004
  5. admyc
    Replies:
    2
    Views:
    228
    Thomas 'PointedEars' Lahn
    Sep 4, 2007
Loading...

Share This Page