Permission denied to get property Location.href

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Mark Bram

    Permission denied to get property Location.href

    Hi All!

    I have a piece of JavaScript that attempts to find the location.href
    property of another window. For example:

    contentWindow =
    window.open('', 'someWindowName ');
    var otherUrl = contentWindow.l ocation.href;

    If it happens to find a window named 'someWindowName ' that currently has a
    document loaded from some other host, the "contentWindow. location.href" code
    triggers the following error:
    Error: uncaught exception: Permission denied to get property
    Location.href

    I know I could put this code inside a try-catch. However, while I found this
    works on IIS5.1 (my testing server), I also found that the version of
    Chilisoft I have to use on the production server does not support
    try-catch...

    So my question is this: how can I avoid the uncaught exception in this case
    without using a try-catch?

    Thanks for any advice!

    Rob
    :)


  • Tim Williams

    #2
    Re: Permission denied to get property Location.href

    Rob,

    Your quoted code looks like client-side script, so I'm puzzled as to what
    possible effect your hosting server ASP environment might have. Use of
    try/catch on the *client* is dependent only on the browser and the js
    version it supports....

    Tim




    "Robert Mark Bram" <relaxedrob@rem ovethis.optusho me.com.au> wrote in message
    news:3faefe35$0 $9224$afc38c87@ news.optusnet.c om.au...[color=blue]
    > Hi All!
    >
    > I have a piece of JavaScript that attempts to find the location.href
    > property of another window. For example:
    >
    > contentWindow =
    > window.open('', 'someWindowName ');
    > var otherUrl = contentWindow.l ocation.href;
    >
    > If it happens to find a window named 'someWindowName ' that currently has a
    > document loaded from some other host, the "contentWindow. location.href"[/color]
    code[color=blue]
    > triggers the following error:
    > Error: uncaught exception: Permission denied to get property
    > Location.href
    >
    > I know I could put this code inside a try-catch. However, while I found[/color]
    this[color=blue]
    > works on IIS5.1 (my testing server), I also found that the version of
    > Chilisoft I have to use on the production server does not support
    > try-catch...
    >
    > So my question is this: how can I avoid the uncaught exception in this[/color]
    case[color=blue]
    > without using a try-catch?
    >
    > Thanks for any advice!
    >
    > Rob
    > :)
    >
    >[/color]


    Comment

    • Robert Mark Bram

      #3
      Re: Permission denied to get property Location.href

      Howdy Tim!
      [color=blue]
      > Your quoted code looks like client-side script, so I'm puzzled as to what
      > possible effect your hosting server ASP environment might have. Use of
      > try/catch on the *client* is dependent only on the browser and the js
      > version it supports....[/color]

      Of course you are right - I was thinking about the error message without
      thinking about it coming from client side. Ignoring the try-catch issue, the
      problem is the same: how can I avoid this error:
      Error: uncaught exception: Permission denied to get property

      Rob
      :)


      Comment

      • Martin Honnen

        #4
        Re: Permission denied to get property Location.href



        Robert Mark Bram wrote:[color=blue]
        > I have a piece of JavaScript that attempts to find the location.href
        > property of another window. For example:
        >
        > contentWindow =
        > window.open('', 'someWindowName ');
        > var otherUrl = contentWindow.l ocation.href;
        >
        > If it happens to find a window named 'someWindowName ' that currently has a
        > document loaded from some other host, the "contentWindow. location.href" code
        > triggers the following error:
        > Error: uncaught exception: Permission denied to get property
        > Location.href[/color]

        Well, you can't change that, as you yourself write the document in the
        other window is loaded from some other host, and the same origin policy
        prevents script from one host to access properties of pages from another
        host. If the hosts are in the same domain e.g.
        host1.domain.tl d
        and
        host2.domain.tl d
        then you can set
        document.domain = 'domain.tld'
        and the cross frame scripting should work, but if the hosts are in
        different domains then there is nothing you can do, unless it is
        Mozilla/Netscape where you could work with signed script.

        --

        Martin Honnen


        Comment

        Working...