473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

JavaScript Works in IE 6, but not IE 7 - Example provided

Hi,

I have some simple JavaScript on my page that worked for years in IE 6
without an error that I am aware of, but does not work in IE 7. Any insight
on this issue that anyone can provide would be greatly appreciated.

Check out the example below in both browsers to see for yourself:
http://216.122.147.105/ie7error.html

NOTE: The above JavaScript functions properly in Netscape 8.n as well.
Nov 28 '06 #1
5 1129
Your if statement is always false:

if (isBrowser.ie5up || isBrowser.nav6up) {

--
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.ajaxpro.info/


"Jason" <il***********@newsgroup.nospamschrieb im Newsbeitrag
news:9D**********************************@microsof t.com...
Hi,

I have some simple JavaScript on my page that worked for years in IE 6
without an error that I am aware of, but does not work in IE 7. Any
insight
on this issue that anyone can provide would be greatly appreciated.

Check out the example below in both browsers to see for yourself:
http://216.122.147.105/ie7error.html

NOTE: The above JavaScript functions properly in Netscape 8.n as well.


Nov 28 '06 #2
Hi,

I think it's because the javascript function in your demo page isn't aware
of more recent IE versions. It's using the UserAgent string to check
browser type. On my system Windows XP SP2 with IE7, the UserAgent string is:

"mozilla/4.0 (compatible; msie 7.0; windows nt 5.1; infopath.2; .net clr
2.0.50727; .net clr 3.0.04506.30; fdm; .net clr 1.1.4322)"

I think you might need to edit following script in function BrowserType():

this.ie = ((agt.indexOf("msie") != -1) && (! this.opera));
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5")==-1)
&& (agt.indexOf("msie 6")==-1) && (agt.indexOf("msie 7")==-1));
this.ie4up = (this.ie && (this.major >= 4));
this.ie5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5")!=-1));
this.ie6 = (this.ie && (this.major == 4) && (agt.indexOf("msie 6")!=-1));
this.ie7 = (this.ie && (this.major == 4) && (agt.indexOf("msie 7")!=-1));
this.ie5up = (this.ie && !this.ie3 && !this.ie4);

However, I don't recommend it since it will easily break if IE 8 is out. I
recommend use following version of browser sniffer javascript:

#JavaScript Browser Sniffer: WebTools - WebReference.com
http://www.webreference.com/tools/br...avascript.html

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 28 '06 #3
Hi,

Walter Wang [MSFT] wrote:
Hi,
<snip>
However, I don't recommend it since it will easily break if IE 8 is out. I
recommend use following version of browser sniffer javascript:

#JavaScript Browser Sniffer: WebTools - WebReference.com
http://www.webreference.com/tools/br...avascript.html
Browser sniffing can always be replaced by object detection, which is
clearly the way to go. Why would you want to remember (or hardcode)
which browser supports which functionality? Just test for it, and act
accordingly.

Example:

var nTextField = null;

if ( document.getElementById )
{
nTextField = document.getElementById( "myTextField" );
}
else
{
if ( document.forms
&& document.forms[ "myForm" ]
&& document.forms[ "myForm" ][ "myTextField" ] )
{
nTextField = document.forms[ "myForm" ][ "myTextField" ];
}
else
{
if ( document.all )
{
nTextField = document.all[ "myTextField" ];
}
}
}

if ( nTextField )
{
// Proceed
}

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 28 '06 #4
Laurent,

Thanks for your input.

I agree that object detection is better and should be used if possible.

#JavaScript - Browser detect
http://www.quirksmode.org/js/detect.html

#Javascript - Object detection
http://www.quirksmode.org/js/support.html
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 29 '06 #5
This is an excellent apporach that I wasn't aware of. Thanks for the advice
and resources guys!

"Walter Wang [MSFT]" wrote:
Laurent,

Thanks for your input.

I agree that object detection is better and should be used if possible.

#JavaScript - Browser detect
http://www.quirksmode.org/js/detect.html

#Javascript - Object detection
http://www.quirksmode.org/js/support.html
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 29 '06 #6

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

Similar topics

0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.