By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 2,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

runtime error ..not an object etc ??

P: n/a
Hello,

One person to date has received a runtime error message saying
"parent.frameleft.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="JavaScript">
<!--
function Home4()
{
parent.f-left.location.href = "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="javascript:parent.Home4();" onMouseOut="MM_swapImgRestore()"
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Geoff Cox" <ge*******@blueyonder.co.uk> wrote in message
news:n3********************************@4ax.com...
One person to date has received a runtime error message saying
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.
"parent.frameleft.location is not an object" ... . <snip>

The identifier "frameleft" does not appear in the code that you posted
so this error message cannot refer to that code.
<script language="JavaScript">
The language attribute has been deprecated in HTML 4 and the type
attribute is required for valid HTML 4:-

<script type="text/javascript">
<!--
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.
function Home4()
{
parent.f-left.location.href = "subject-left.htm";
parent.f-right.location.href = "info-right.htm";
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";
}
}
}
// -->
</script>
<snip><a href="javascript:parent.Home4();"
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 >
onMouseOut="MM_swapImgRestore()"


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.
Jul 20 '05 #2

P: n/a
On Wed, 19 Nov 2003 07:04:12 -0000, "Richard Cornford"
<Ri*****@litotes.demon.co.uk> wrote:
"Geoff Cox" <ge*******@blueyonder.co.uk> wrote in message
news:n3********************************@4ax.com.. .
One person to date has received a runtime error message saying
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.


Richard,

apologies - my mistake - it should have read

<script language="JavaScript">
<!--
function Home4()
{
parent.frameleft.location.href = "subject-left.htm";
parent.frameright.location.href = "info-right.htm";
}
// -->
</script>

will read your answer now ...

Thanks

Geoff
"parent.frameleft.location is not an object" ... .

<snip>

The identifier "frameleft" does not appear in the code that you posted
so this error message cannot refer to that code.
<script language="JavaScript">


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

<script type="text/javascript">
<!--


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.
function Home4()
{
parent.f-left.location.href = "subject-left.htm";
parent.f-right.location.href = "info-right.htm";


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";
}
}
}
// -->
</script>


<snip>
<a href="javascript:parent.Home4();"


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 >
onMouseOut="MM_swapImgRestore()"


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.


Jul 20 '05 #3

P: n/a
On Wed, 19 Nov 2003 07:04:12 -0000, "Richard Cornford"
<Ri*****@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

"Geoff Cox" <ge*******@blueyonder.co.uk> wrote in message
news:n3********************************@4ax.com.. .
One person to date has received a runtime error message saying


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.
"parent.frameleft.location is not an object" ... .

<snip>

The identifier "frameleft" does not appear in the code that you posted
so this error message cannot refer to that code.
<script language="JavaScript">


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

<script type="text/javascript">
<!--


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.
function Home4()
{
parent.f-left.location.href = "subject-left.htm";
parent.f-right.location.href = "info-right.htm";


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";
}
}
}
// -->
</script>


<snip>
<a href="javascript:parent.Home4();"


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 >
onMouseOut="MM_swapImgRestore()"


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.


Jul 20 '05 #4

P: n/a
JRS: In article <bp*******************@news.demon.co.uk>, seen in
news:comp.lang.javascript, Richard Cornford
<Ri*****@litotes.demon.co.uk> posted at Wed, 19 Nov 2003 07:04:12 :-

(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.)


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.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.