As the subject states, I'm having issues with if else statements that
are testing true in IE but false in Mozilla. At first I Thought maybe
the way I was splitting the string was leaving trailing white spaces
in Mozilla, but that was not the case (as the alert in the else
statement shows). So I'm at a complete loss here. The reason for this
script is to make the button mouse overs to remain active on their
respective pages, without having to hard code it on each respective
page. The reason is because the buttons are in an include file (which
is a temp fix until we get the whole site running on a database).
Here is the code (for whatever reason Mozila only runs the alert in
the else statement.):
function PageName() {
var NextPage = new String(location.href);
var ArrNextPage = NextPage.split("/");
var NextPage2 = new String(ArrNextPage[eval(ArrNextPage.length -
1)]);
var ArrNextPage2 = NextPage2.split(".");
var NextPage3 = new String(ArrNextPage2[0]);
if (NextPage3 == "massage") {
VV_swapImage('massage','','./images/massageOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('massageLink','','show');
} else if (NextPage3 == "ballFitness") {
VV_swapImage('ballFitness','','./images/ballFitnessOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('ballFitnessLink','','show');
} else if (NextPage3 == "bellydance") {
VV_swapImage('bellydance','','./images/bellydanceOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('bellydanceLink','','show');
} else if (NextPage3 == "danceFitness") {
VV_swapImage('dance','','./images/danceOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('danceFitnessLink','','show');
} else if (NextPage3 == "yoga") {
VV_swapImage('yoga','','./images/yogaOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('yogaLink','','show');
} else if (NextPage3 == "wellness") {
VV_swapImage('taiChi','','./images/taiChiOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('taiChiLink','','show');
} else if (NextPage3 == "pilates") {
VV_swapImage('pilates','','./images/pilatesOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('pilatesLink','','show');
} else if (NextPage3 == "transform") {
VV_swapImage('fitness','','./images/fitnessOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('fitnessLink','','show');
} else if (NextPage3 == "pregnancyFitness") {
VV_swapImage('pregnancy','','./images/pregnancyOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('pregnancyLink','','show');
} else if (NextPage3 == "relaxation") {
VV_swapImage('relaxation','','./images/relaxationOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('relaxationLink','','show');
} else if (NextPage3 == "backcare") {
VV_swapImage('backcare','','./images/backcareOver.jpg',1);
VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG');
VV_showHideLayers('backcareLink','','show');
} else {
alert('3' + NextPage3 + '3');
}
} 6 1383
The Bator writes: As the subject states, I'm having issues with if else statements that are testing true in IE but false in Mozilla. At first I Thought maybe the way I was splitting the string was leaving trailing white spaces in Mozilla, but that was not the case (as the alert in the else statement shows). So I'm at a complete loss here. The reason for this script is to make the button mouse overs to remain active on their respective pages, without having to hard code it on each respective page. The reason is because the buttons are in an include file (which is a temp fix until we get the whole site running on a database).
Here is the code (for whatever reason Mozila only runs the alert in the else statement.):
function PageName() { var NextPage = new String(location.href); var ArrNextPage = NextPage.split("/"); var NextPage2 = new String(ArrNextPage[eval(ArrNextPage.length - 1)]); var ArrNextPage2 = NextPage2.split("."); var NextPage3 = new String(ArrNextPage2[0]);
There are two suspicious things here. First, don't use the String constructor.
This isn't Java. You never have to say
new String(...)
Strangely, the String constructor makes an object, not a string. Get rid of it.
Second, you are using eval(), which is strictly for the tards. Clean it up and
try again. http://www.ecmascript.net/
"The Master" <tg****@goldhil.com> wrote in message
news:a2**************************@posting.google.c om... As the subject states, I'm having issues with if else statements that are testing true in IE but false in Mozilla. At first I Thought maybe the way I was splitting the string was leaving trailing white spaces in Mozilla, but that was not the case (as the alert in the else statement shows). So I'm at a complete loss here. The reason for this script is to make the button mouse overs to remain active on their respective pages, without having to hard code it on each respective page. The reason is because the buttons are in an include file (which is a temp fix until we get the whole site running on a database).
Here is the code (for whatever reason Mozila only runs the alert in the else statement.):
function PageName() { var NextPage = new String(location.href); var ArrNextPage = NextPage.split("/"); var NextPage2 = new String(ArrNextPage[eval(ArrNextPage.length - 1)]); var ArrNextPage2 = NextPage2.split("."); var NextPage3 = new String(ArrNextPage2[0]);
if (NextPage3 == "massage") {
maybe: NextPage3.toLowerCase() // just in case the href is mixed or uppercase
VV_swapImage('massage','','./images/massageOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('massageLink','','show');
} else if (NextPage3 == "ballFitness") { VV_swapImage('ballFitness','','./images/ballFitnessOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('ballFitnessLink','','show');
} else if (NextPage3 == "bellydance") { VV_swapImage('bellydance','','./images/bellydanceOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('bellydanceLink','','show');
} else if (NextPage3 == "danceFitness") { VV_swapImage('dance','','./images/danceOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('danceFitnessLink','','show');
} else if (NextPage3 == "yoga") { VV_swapImage('yoga','','./images/yogaOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('yogaLink','','show');
} else if (NextPage3 == "wellness") { VV_swapImage('taiChi','','./images/taiChiOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('taiChiLink','','show');
} else if (NextPage3 == "pilates") { VV_swapImage('pilates','','./images/pilatesOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('pilatesLink','','show');
} else if (NextPage3 == "transform") { VV_swapImage('fitness','','./images/fitnessOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('fitnessLink','','show');
} else if (NextPage3 == "pregnancyFitness") { VV_swapImage('pregnancy','','./images/pregnancyOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('pregnancyLink','','show');
} else if (NextPage3 == "relaxation") { VV_swapImage('relaxation','','./images/relaxationOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('relaxationLink','','show');
} else if (NextPage3 == "backcare") { VV_swapImage('backcare','','./images/backcareOver.jpg',1); VV_changeProp('navChange','','src','./images/navChangeOver.jpg','IMG'); VV_showHideLayers('backcareLink','','show'); } else { alert('3' + NextPage3 + '3'); } }
Thanks that fixed the issue for Netscape/Mozilla. Which makes me
currious as to why it now works for Netscape/mozilla? Also what is the
tards?
Do you know of a really good Javascript book that teaches the proper
syntax. Since I'm finding that every so often that javascript
exlpination online can tend to give you bad syntax examples.
Sincerely,
The Master
The Bator writes: There are two suspicious things here. First, don't use the >String
constructor.This isn't Java. You never have to say new String(...) Strangely, the String constructor makes an object, not a >string. Get
rid of it.Second, you are using eval(), which is strictly for the >tards. Clean
it up andtry again.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
> >There are two suspicious things here. First, don't use the String constructor. This isn't Java. You never have to say new String(...) Strangely, the String constructor makes an object, not a string. Get rid of it. Second, you are using eval(), which is strictly for the tards. Clean it up and try again.
Thanks that fixed the issue for Netscape/Mozilla. Which makes me currious as to why it now works for Netscape/mozilla? Also what is the tards?
The standards on which The Web is based are the most faulty and least complied
with of all international technical standards. If you want your stuff to work on
a variety of browsers, you need to restrict yourself to those features which are
best specified and best complied with. jslint is a tool that can help you there: http://www.crockford.com/javascript/lint.html
Do you know of a really good Javascript book that teaches the proper syntax. Since I'm finding that every so often that javascript exlpination online can tend to give you bad syntax examples.
Nearly all JavaScript books are quite awful. Recommendations on good ones can be
found here: http://www.crockford.com/javascript/javascript.html
JRS: In article <a2**************************@posting.google.com >, seen
in news:comp.lang.javascript, The Master <tg****@goldhil.com> posted at
Mon, 19 Jan 2004 08:52:22 :- As the subject states, I'm having issues with if else statements that are testing true in IE but false in Mozilla. At first I Thought maybe the way I was splitting the string was leaving trailing white spaces in Mozilla, but that was not the case (as the alert in the else statement shows). So I'm at a complete loss here. The reason for this script is to make the button mouse overs to remain active on their respective pages, without having to hard code it on each respective page. The reason is because the buttons are in an include file (which is a temp fix until we get the whole site running on a database).
Simplify before posting. Almost certainly. the problem remains with
only two cases; and with alert(number) instead of VV triplets. If it
does not, that's valuable evidence.
For test, show the value of NextPage3 before testing it; it may well not
be what you think it is.
Your function appears to depend only on location.href; that should, for
easier testing, be a parameter.
Your eval() is superfluous. Your new String() are superfluous.
NextPage3 could more briefly be extracted by a RegExp; a RegExp expert
should be here shortly. The following gives 'frequent', and may be
right :
S = "C:/HOMEPAGE/frequent.htm"
S = S.match(/\/([^\/]*)(\..*)/)[1] // .toLowerCase()
The code might be neater using a switch
switch (NextPage3) {
case "massage" : { VV() ; VV() ; VV() }
case ...
...
default : : {...} }
Since the VV triplets are so repetitive, replace each triplet with a
single function call using three parameters, or even one.
Don't call yourself "The Master" until you deserve it; it has an effect
on your readers which you should not be wanting.
--
© 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> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
>NextPage3 could more briefly be extracted by a RegExp; a >RegExp expert
should be here shortly. The following >gives 'frequent', and may be
right : S = "C:/HOMEPAGE/frequent.htm" S = S.match(/\/([^\/]*)(\..*)/)[1] // .toLowerCase()
The code might be neater using a switch
switch (NextPage3) { case "massage" : { VV() ; VV() ; VV() } case ... ... default : : {...} }
Since the VV triplets are so repetitive, replace each >triplet with a
single function call using three >parameters, or even one.
Thanks for the Tips.
Don't call yourself "The Master" until you deserve it; it >has an
effect on your readers which you should not be >wanting.
Come on don't tell me you haven't seen Dr Who. The Master was hardly a
genious as the good ole Dr always beat him.
Sincerely,
The Master
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by Sims |
last post: by
|
15 posts
views
Thread by Peter Bremer |
last post: by
|
15 posts
views
Thread by F. Da Costa |
last post: by
|
13 posts
views
Thread by jstanforth |
last post: by
|
1 post
views
Thread by cwdjrxyz |
last post: by
|
4 posts
views
Thread by Randy |
last post: by
|
37 posts
views
Thread by spam.noam |
last post: by
|
10 posts
views
Thread by News |
last post: by
|
43 posts
views
Thread by michael.f.ellis |
last post: by
| | | | | | | | | | |