473,769 Members | 3,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1153
Your if statement is always false:

if (isBrowser.ie5u p || isBrowser.nav6u p) {

--
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.nospa mschrieb im Newsbeitrag
news:9D******** *************** ***********@mic rosoft.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("m sie 5")==-1)
&& (agt.indexOf("m sie 6")==-1) && (agt.indexOf("m sie 7")==-1));
this.ie4up = (this.ie && (this.major >= 4));
this.ie5 = (this.ie && (this.major == 4) && (agt.indexOf("m sie 5")!=-1));
this.ie6 = (this.ie && (this.major == 4) && (agt.indexOf("m sie 6")!=-1));
this.ie7 = (this.ie && (this.major == 4) && (agt.indexOf("m sie 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.co m
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.co m
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.getEle mentById )
{
nTextField = document.getEle mentById( "myTextFiel d" );
}
else
{
if ( document.forms
&& document.forms[ "myForm" ]
&& document.forms[ "myForm" ][ "myTextFiel d" ] )
{
nTextField = document.forms[ "myForm" ][ "myTextFiel d" ];
}
else
{
if ( document.all )
{
nTextField = document.all[ "myTextFiel d" ];
}
}
}

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
9423
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
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
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
6673
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
5298
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...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
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.