runtime error ..not an object etc ??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Cox

    runtime error ..not an object etc ??

    Hello,

    One person to date has received a runtime error message saying
    "parent.framele ft.location is not an object" with the following code.
    The code is used to select 2 frames at the same time...

    Any ideas why please?

    Geoff

    <script language="JavaS cript">
    <!--
    function Home4()
    {
    parent.f-left.location.h ref = "subject-left.htm";
    parent.f-right.location. href = "info-right.htm";
    }
    // -->
    </script>

    above is called from another page by the line (by clicking on a
    button)

    <a href="javascrip t:parent.Home4( );" onMouseOut="MM_ swapImgRestore( )"


  • Richard Cornford

    #2
    Re: runtime error ..not an object etc ??

    "Geoff Cox" <geoff.cox@blue yonder.co.uk> wrote in message
    news:n3qkrvgomn s5qnmvssv6l99ku jjrl0oe9f@4ax.c om...[color=blue]
    >One person to date has received a runtime error message saying[/color]

    If the code that you posted is the code you are using (and if not why
    did you post it?) then it is surprising that it works for anyone.
    [color=blue]
    >"parent.framel eft.location is not an object" ... .[/color]
    <snip>

    The identifier "frameleft" does not appear in the code that you posted
    so this error message cannot refer to that code.
    [color=blue]
    ><script language="JavaS cript">[/color]

    The language attribute has been deprecated in HTML 4 and the type
    attribute is required for valid HTML 4:-

    <script type="text/javascript">
    [color=blue]
    ><!--[/color]

    This "hide from older browsers" stuff is no longer required as the
    browsers that were young when it was introduced are now so old
    themselves as to have gone out of use.
    [color=blue]
    >function Home4()
    >{
    >parent.f-left.location.h ref = "subject-left.htm";
    >parent.f-right.location. href = "info-right.htm";[/color]

    In JavaScript the hyphen ( - ) is the subtraction operator so the above
    lines of code are attempting to subtract the value of left.location.h ref
    from the value of parent.f and assign a string to the (if it worked,
    numeric (probably NaN)) result. That guarantees that both lines would
    produce at least one error and more likely several (though execution
    would stop at the first).

    If you have used the IDs/names "f-left" and "f-right" for frames in a
    frameset then the problem that you cannot use a hyphen in a JavaScript
    identifier can be avoided using square bracket notation:-

    <URL: http://www.jibbering.com/faq/#FAQ4_39 >

    It would probably be best to use name attributes and access the frames
    from the "frames" collection of the parent object (using bracket
    notation) and assign the string values directly to the location property
    rather than its href property.

    parent.frames['f-left'].location = "subject-left.htm";

    (Incidentally, I have often read recommendations against using hyphens
    in file names over the Internet (underscore characters are recommended
    alternatives) but I have no idea how significant that is as I have never
    used a hyphen in a file name.)

    There is always a chance that any given browser that the script
    encounters may not implement all of the objects required by your script.
    As a result it is usually a good idea to verify the existence of browser
    features before using them (so that otherwise predictable errors are not
    generated and to provide an opportunity for active fall-back/controlled
    degredation). Exactly how that would be implemented most efficiently
    depends on factors that are not obvious from your posted code, but might
    be as simple as wrapping the two assignments to the locations in - if -
    tests:-

    if((typeof parent != 'undefined')&&( parent.frames)) {
    if((parent.fram es['f-left'])&&(parent.fram es['f-left'].location)){
    parent.frames['f-left'].location = "subject-left.htm";
    }
    if((parent.fram es['f-right'])&&(parent.fram es['f-right'].location)){
    parent.frames['f-right'].location = "subject-right.htm";
    }
    }
    [color=blue]
    >}
    >// -->
    ></script>[/color]

    <snip>[color=blue]
    ><a href="javascrip t:parent.Home4( );"[/color]

    javascript pseudo-protocol HREFs are a bad idea. Instead the onclick
    event handling attribute should be used (returning false to cancel the
    navigation in the HREF) along with a real HREF for the users with
    JavaScript disabled/unavailable.

    <URL: http://www.jibbering.com/faq/#FAQ4_24 >
    [color=blue]
    >onMouseOut="MM _swapImgRestore ()"[/color]

    The Macromedia generated JavaScript functions are some of the worst
    JavaScript ever written. You don't have to learn much to implement
    alternatives an order of magnitude better yourself (especially if you
    never take a Macromedia function as an example of anything except what
    to avoid).

    Richard.


    Comment

    • Geoff Cox

      #3
      Re: runtime error ..not an object etc ??

      On Wed, 19 Nov 2003 07:04:12 -0000, "Richard Cornford"
      <Richard@litote s.demon.co.uk> wrote:
      [color=blue]
      >"Geoff Cox" <geoff.cox@blue yonder.co.uk> wrote in message
      >news:n3qkrvgom ns5qnmvssv6l99k ujjrl0oe9f@4ax. com...[color=green]
      >>One person to date has received a runtime error message saying[/color]
      >
      >If the code that you posted is the code you are using (and if not why
      >did you post it?) then it is surprising that it works for anyone.[/color]

      Richard,

      apologies - my mistake - it should have read

      <script language="JavaS cript">
      <!--
      function Home4()
      {
      parent.framelef t.location.href = "subject-left.htm";
      parent.framerig ht.location.hre f = "info-right.htm";
      }
      // -->
      </script>

      will read your answer now ...

      Thanks

      Geoff
      [color=blue]
      >[color=green]
      >>"parent.frame left.location is not an object" ... .[/color]
      ><snip>
      >
      >The identifier "frameleft" does not appear in the code that you posted
      >so this error message cannot refer to that code.
      >[color=green]
      >><script language="JavaS cript">[/color]
      >
      >The language attribute has been deprecated in HTML 4 and the type
      >attribute is required for valid HTML 4:-
      >
      ><script type="text/javascript">
      >[color=green]
      >><!--[/color]
      >
      >This "hide from older browsers" stuff is no longer required as the
      >browsers that were young when it was introduced are now so old
      >themselves as to have gone out of use.
      >[color=green]
      >>function Home4()
      >>{
      >>parent.f-left.location.h ref = "subject-left.htm";
      >>parent.f-right.location. href = "info-right.htm";[/color]
      >
      >In JavaScript the hyphen ( - ) is the subtraction operator so the above
      >lines of code are attempting to subtract the value of left.location.h ref
      >from the value of parent.f and assign a string to the (if it worked,
      >numeric (probably NaN)) result. That guarantees that both lines would
      >produce at least one error and more likely several (though execution
      >would stop at the first).
      >
      >If you have used the IDs/names "f-left" and "f-right" for frames in a
      >frameset then the problem that you cannot use a hyphen in a JavaScript
      >identifier can be avoided using square bracket notation:-
      >
      ><URL: http://www.jibbering.com/faq/#FAQ4_39 >
      >
      >It would probably be best to use name attributes and access the frames
      >from the "frames" collection of the parent object (using bracket
      >notation) and assign the string values directly to the location property
      >rather than its href property.
      >
      >parent.frame s['f-left'].location = "subject-left.htm";
      >
      >(Incidentall y, I have often read recommendations against using hyphens
      >in file names over the Internet (underscore characters are recommended
      >alternatives ) but I have no idea how significant that is as I have never
      >used a hyphen in a file name.)
      >
      >There is always a chance that any given browser that the script
      >encounters may not implement all of the objects required by your script.
      >As a result it is usually a good idea to verify the existence of browser
      >features before using them (so that otherwise predictable errors are not
      >generated and to provide an opportunity for active fall-back/controlled
      >degredation) . Exactly how that would be implemented most efficiently
      >depends on factors that are not obvious from your posted code, but might
      >be as simple as wrapping the two assignments to the locations in - if -
      >tests:-
      >
      >if((typeof parent != 'undefined')&&( parent.frames)) {
      > if((parent.fram es['f-left'])&&(parent.fram es['f-left'].location)){
      > parent.frames['f-left'].location = "subject-left.htm";
      > }
      > if((parent.fram es['f-right'])&&(parent.fram es['f-right'].location)){
      > parent.frames['f-right'].location = "subject-right.htm";
      > }
      >}
      >[color=green]
      >>}
      >>// -->
      >></script>[/color]
      >
      ><snip>[color=green]
      >><a href="javascrip t:parent.Home4( );"[/color]
      >
      >javascript pseudo-protocol HREFs are a bad idea. Instead the onclick
      >event handling attribute should be used (returning false to cancel the
      >navigation in the HREF) along with a real HREF for the users with
      >JavaScript disabled/unavailable.
      >
      ><URL: http://www.jibbering.com/faq/#FAQ4_24 >
      >[color=green]
      >>onMouseOut="M M_swapImgRestor e()"[/color]
      >
      >The Macromedia generated JavaScript functions are some of the worst
      >JavaScript ever written. You don't have to learn much to implement
      >alternatives an order of magnitude better yourself (especially if you
      >never take a Macromedia function as an example of anything except what
      >to avoid).
      >
      >Richard.
      >[/color]

      Comment

      • Geoff Cox

        #4
        Re: runtime error ..not an object etc ??

        On Wed, 19 Nov 2003 07:04:12 -0000, "Richard Cornford"
        <Richard@litote s.demon.co.uk> wrote:

        Richard,

        if I have understood you correctly so far I have changed the code with
        the select button to

        <a href="withjs.ht m" target = "_top" onclick="parent .Home4();return
        false" etc

        In fact at the moment because of the runtime error I have fallen back
        to using no javascript and using a different frameset for each
        combination of 2 pages ...

        It seems that I can use the above javascript code as if javascript is
        not enabled the withjs.htm uses the frameset only approach.

        Can you see any errors/problems?!

        Thanks

        Geoff

        [color=blue]
        >"Geoff Cox" <geoff.cox@blue yonder.co.uk> wrote in message
        >news:n3qkrvgom ns5qnmvssv6l99k ujjrl0oe9f@4ax. com...[color=green]
        >>One person to date has received a runtime error message saying[/color]
        >
        >If the code that you posted is the code you are using (and if not why
        >did you post it?) then it is surprising that it works for anyone.
        >[color=green]
        >>"parent.frame left.location is not an object" ... .[/color]
        ><snip>
        >
        >The identifier "frameleft" does not appear in the code that you posted
        >so this error message cannot refer to that code.
        >[color=green]
        >><script language="JavaS cript">[/color]
        >
        >The language attribute has been deprecated in HTML 4 and the type
        >attribute is required for valid HTML 4:-
        >
        ><script type="text/javascript">
        >[color=green]
        >><!--[/color]
        >
        >This "hide from older browsers" stuff is no longer required as the
        >browsers that were young when it was introduced are now so old
        >themselves as to have gone out of use.
        >[color=green]
        >>function Home4()
        >>{
        >>parent.f-left.location.h ref = "subject-left.htm";
        >>parent.f-right.location. href = "info-right.htm";[/color]
        >
        >In JavaScript the hyphen ( - ) is the subtraction operator so the above
        >lines of code are attempting to subtract the value of left.location.h ref
        >from the value of parent.f and assign a string to the (if it worked,
        >numeric (probably NaN)) result. That guarantees that both lines would
        >produce at least one error and more likely several (though execution
        >would stop at the first).
        >
        >If you have used the IDs/names "f-left" and "f-right" for frames in a
        >frameset then the problem that you cannot use a hyphen in a JavaScript
        >identifier can be avoided using square bracket notation:-
        >
        ><URL: http://www.jibbering.com/faq/#FAQ4_39 >
        >
        >It would probably be best to use name attributes and access the frames
        >from the "frames" collection of the parent object (using bracket
        >notation) and assign the string values directly to the location property
        >rather than its href property.
        >
        >parent.frame s['f-left'].location = "subject-left.htm";
        >
        >(Incidentall y, I have often read recommendations against using hyphens
        >in file names over the Internet (underscore characters are recommended
        >alternatives ) but I have no idea how significant that is as I have never
        >used a hyphen in a file name.)
        >
        >There is always a chance that any given browser that the script
        >encounters may not implement all of the objects required by your script.
        >As a result it is usually a good idea to verify the existence of browser
        >features before using them (so that otherwise predictable errors are not
        >generated and to provide an opportunity for active fall-back/controlled
        >degredation) . Exactly how that would be implemented most efficiently
        >depends on factors that are not obvious from your posted code, but might
        >be as simple as wrapping the two assignments to the locations in - if -
        >tests:-
        >
        >if((typeof parent != 'undefined')&&( parent.frames)) {
        > if((parent.fram es['f-left'])&&(parent.fram es['f-left'].location)){
        > parent.frames['f-left'].location = "subject-left.htm";
        > }
        > if((parent.fram es['f-right'])&&(parent.fram es['f-right'].location)){
        > parent.frames['f-right'].location = "subject-right.htm";
        > }
        >}
        >[color=green]
        >>}
        >>// -->
        >></script>[/color]
        >
        ><snip>[color=green]
        >><a href="javascrip t:parent.Home4( );"[/color]
        >
        >javascript pseudo-protocol HREFs are a bad idea. Instead the onclick
        >event handling attribute should be used (returning false to cancel the
        >navigation in the HREF) along with a real HREF for the users with
        >JavaScript disabled/unavailable.
        >
        ><URL: http://www.jibbering.com/faq/#FAQ4_24 >
        >[color=green]
        >>onMouseOut="M M_swapImgRestor e()"[/color]
        >
        >The Macromedia generated JavaScript functions are some of the worst
        >JavaScript ever written. You don't have to learn much to implement
        >alternatives an order of magnitude better yourself (especially if you
        >never take a Macromedia function as an example of anything except what
        >to avoid).
        >
        >Richard.
        >[/color]

        Comment

        • Dr John Stockton

          #5
          Re: runtime error ..not an object etc ??

          JRS: In article <bpf4lb$k6f$1$8 30fa78d@news.de mon.co.uk>, seen in
          news:comp.lang. javascript, Richard Cornford
          <Richard@litote s.demon.co.uk> posted at Wed, 19 Nov 2003 07:04:12 :-[color=blue]
          >
          >(Incidentall y, I have often read recommendations against using hyphens
          >in file names over the Internet (underscore characters are recommended
          >alternatives ) but I have no idea how significant that is as I have never
          >used a hyphen in a file name.)
          >[/color]

          All my javascript page names have them, and more than half of the total
          *.htm in the master root directory. No complaints, IIRC.

          One reason for avoiding them could be that nasty MS software used also
          for WP may use em- or en-dash instead. The remedy is clear.

          --
          © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
          <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
          <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
          <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

          Comment

          Working...