473,811 Members | 3,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Str comparison tests true in IE; false in Mozilla/Netscape

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(ArrNextP age[eval(ArrNextPag e.length -
1)]);
var ArrNextPage2 = NextPage2.split (".");
var NextPage3 = new String(ArrNextP age2[0]);

if (NextPage3 == "massage") {
VV_swapImage('m assage','','./images/massageOver.jpg ',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('massageLink ','','show');

} else if (NextPage3 == "ballFitnes s") {
VV_swapImage('b allFitness','', './images/ballFitnessOver .jpg',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('ballFitness Link','','show' );

} else if (NextPage3 == "bellydance ") {
VV_swapImage('b ellydance','',' ./images/bellydanceOver. jpg',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('bellydanceL ink','','show') ;

} else if (NextPage3 == "danceFitne ss") {
VV_swapImage('d ance','','./images/danceOver.jpg', 1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('danceFitnes sLink','','show ');

} else if (NextPage3 == "yoga") {
VV_swapImage('y oga','','./images/yogaOver.jpg',1 );
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('yogaLink',' ','show');

} else if (NextPage3 == "wellness") {
VV_swapImage('t aiChi','','./images/taiChiOver.jpg' ,1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('taiChiLink' ,'','show');

} else if (NextPage3 == "pilates") {
VV_swapImage('p ilates','','./images/pilatesOver.jpg ',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('pilatesLink ','','show');

} else if (NextPage3 == "transform" ) {
VV_swapImage('f itness','','./images/fitnessOver.jpg ',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('fitnessLink ','','show');

} else if (NextPage3 == "pregnancyFitne ss") {
VV_swapImage('p regnancy','','./images/pregnancyOver.j pg',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('pregnancyLi nk','','show');

} else if (NextPage3 == "relaxation ") {
VV_swapImage('r elaxation','',' ./images/relaxationOver. jpg',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('relaxationL ink','','show') ;

} else if (NextPage3 == "backcare") {
VV_swapImage('b ackcare','','./images/backcareOver.jp g',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('backcareLin k','','show');
} else {
alert('3' + NextPage3 + '3');
}
}
Jul 20 '05 #1
6 1490
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(ArrNextP age[eval(ArrNextPag e.length -
1)]);
var ArrNextPage2 = NextPage2.split (".");
var NextPage3 = new String(ArrNextP age2[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/

Jul 20 '05 #2

"The Master" <tg****@goldhil .com> wrote in message
news:a2******** *************** ***@posting.goo gle.com...
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(ArrNextP age[eval(ArrNextPag e.length -
1)]);
var ArrNextPage2 = NextPage2.split (".");
var NextPage3 = new String(ArrNextP age2[0]);

if (NextPage3 == "massage") {
maybe: NextPage3.toLow erCase() // just in case the href is mixed or uppercase

VV_swapImage('m assage','','./images/massageOver.jpg ',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('massageLink ','','show');

} else if (NextPage3 == "ballFitnes s") {
VV_swapImage('b allFitness','', './images/ballFitnessOver .jpg',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('ballFitness Link','','show' );

} else if (NextPage3 == "bellydance ") {
VV_swapImage('b ellydance','',' ./images/bellydanceOver. jpg',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('bellydanceL ink','','show') ;

} else if (NextPage3 == "danceFitne ss") {
VV_swapImage('d ance','','./images/danceOver.jpg', 1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('danceFitnes sLink','','show ');

} else if (NextPage3 == "yoga") {
VV_swapImage('y oga','','./images/yogaOver.jpg',1 );
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('yogaLink',' ','show');

} else if (NextPage3 == "wellness") {
VV_swapImage('t aiChi','','./images/taiChiOver.jpg' ,1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('taiChiLink' ,'','show');

} else if (NextPage3 == "pilates") {
VV_swapImage('p ilates','','./images/pilatesOver.jpg ',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('pilatesLink ','','show');

} else if (NextPage3 == "transform" ) {
VV_swapImage('f itness','','./images/fitnessOver.jpg ',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('fitnessLink ','','show');

} else if (NextPage3 == "pregnancyFitne ss") {
VV_swapImage('p regnancy','','./images/pregnancyOver.j pg',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('pregnancyLi nk','','show');

} else if (NextPage3 == "relaxation ") {
VV_swapImage('r elaxation','',' ./images/relaxationOver. jpg',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('relaxationL ink','','show') ;

} else if (NextPage3 == "backcare") {
VV_swapImage('b ackcare','','./images/backcareOver.jp g',1);
VV_changeProp(' navChange','',' src','./images/navChangeOver.j pg','IMG');
VV_showHideLaye rs('backcareLin k','','show');
} else {
alert('3' + NextPage3 + '3');
}
}

Jul 20 '05 #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!
Jul 20 '05 #4
> >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

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5038
by: Sims | last post by:
Hi, if i use... // php $info = getenv("HTTP_USER_AGENT"); // I noticed that Mozzila and Netscape <6(?) both use the same Agent. // so i was thinking of if (preg_match("/Mozilla/i", $info)) {
15
7311
by: Peter Bremer | last post by:
Hi all, I've written this little piece of code, which doesn't seem to work in Mozilla 1.5. I haven't tried it on other Gecko browsers, but I've found some indication that Netscape 6+ has the same problem. Internet Explorer 6 and Opera 7 have no problems with it. <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'> <script>document.write (window.history.length);</script>
15
2335
by: F. Da Costa | last post by:
Hi all, Following two sniperts of code I'm using and getting very interesting results from. ..html <tr id="1" class="segment" open="false"> This is the segment under 'investigation' ..js
13
4651
by: jstanforth | last post by:
This is probably a very obvious question, but I'm not clear on what operators need to be implemented for std::map.find() to work. For example, I have a class MyString that wraps std::string, and which also implements ==, <, <=, >, >=, etc. (Those operators are tested and working correctly.) If I assign map = "world", it saves the MyString's correctly in the map. But a subsequent call to map.find("hello") returns map.end(). Even more...
1
1906
by: cwdjrxyz | last post by:
I am now writing many new pages in xhtml 1.1. They are served as true xhtml by setting the mime type of the server to application/xhtml+xml for the .xhtml extension. Since IE6 and some earlier browsers can not handle this mime type, a simple php include is at the very top of such pages. If the mentioned mime type support for the viewing browser is detected, everything above the head tag of the page is written in xhtml 1.1 code. If the...
4
16069
by: Randy | last post by:
Hello, In comparing strings, is it just as well to use... string1 == string2 or is it better for any reason to use the String.Compare of String.Equals? Thanks
37
2826
by: spam.noam | last post by:
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, "{} < " will raise a TypeError instead of the current behaviour, which is returning a value which is, really, id({}) < id(). He also said that default equality comparison will continue to be identity-based. This means that x == y will never raise an exception, as is the situation is now. Here's his reason:
10
2380
by: News | last post by:
I have a page up trying to learn how to ID a browser and other info. http://wyght.com/warren/testPos.html here is the code <script type = "text/javascript"> var space = ", "; var name = navigator.appName;
43
2749
by: michael.f.ellis | last post by:
The following script puzzles me. It creates two nested lists that compare identically. After identical element assignments, the lists are different. In one case, a single element is replaced. In the other, an entire column is replaced. --------------------------------------------------------------------------------------- ''' An oddity in the behavior of lists of lists. Occurs under Python 2.4.3 (#69, Mar 29 2006, 17:35:34)
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10395
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10130
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7667
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6887
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5553
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.