On Wed, 19 Nov 2003 07:04:12 -0000, "Richard Cornford"
<Richard@litotes.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.htm" 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@blueyonder.co.uk> wrote in message
>news:n3qkrvgomns5qnmvssv6l99kujjrl0oe9f@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.frameleft.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="JavaScript">[/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.href = "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.href
>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.frames['f-left'])&&(parent.frames['f-left'].location)){
> parent.frames['f-left'].location = "subject-left.htm";
> }
> if((parent.frames['f-right'])&&(parent.frames['f-right'].location)){
> parent.frames['f-right'].location = "subject-right.htm";
> }
>}
>[color=green]
>>}
>>// -->
>></script>[/color]
>
><snip>[color=green]
>><a href="javascript
: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="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.
>[/color]