473,811 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

test for onscroll support

Hi!

I use the onscroll event to make something like the CSS position:fixed; for
MSIE.

In MSIE/5.5, before a function is assigned to the event handler, it has the
value null. In Opera, it is undefined, because Opera doesn't support this
event.

I use:

if(window.onscr oll===undefined || some_other_stuf f)
do_something_el se()
else
window.onscroll =myfunction

to check if it will work. Now this works in MSIE/5.5 and Opera, but in
MSIE/5.0, it seems that the keyword 'undefined' is itself not defined.

***
How can I test for the presence of this event handler without causing an
error mesage in MSIE/5.0 ?
***

Obviously, just if(window.onscr oll) won't work because both undefined and
null are boolean false.

You can see this in action (or not) at:

http://www.touchwoodfurniture.co.uk/

This site is new, so any other comments are welcomed.

The script is:

http://www.touchwoodfurniture.co.uk/scripts/ie5_foot.js

(The equiv. for other browsers is css2_foot.js)

Thanks!
Tom Vajzovic <webmaster@[the above domain]>

Jul 20 '05 #1
3 10489
and then Dom Leonard said:
viza wrote:
Hi!

if(window.onscr oll===undefined || some_other_stuf f)
do_something_el se()
else
window.onscroll =myfunction

to check if it will work. Now this works in MSIE/5.5 and Opera, but in
MSIE/5.0, it seems that the keyword 'undefined' is itself not defined.

Which is true - undefined is not a keyword, and is being treated as an
identifier for which there is no declaration. This *should* generate a
ReferenceType error when getting the value and does so under IE5.0.
However, Mozilla and Opera seem to have predefined a window property
named "undefined" with the primitive value 'undefined' to get around the
error. Can't exactly test what IE6 has done (window.hasOwnP roperty is,
well ummm, undefined) but I presume it has done something similar since
release of IE5.5. Note that although window.undefine d exists in the
browsers tested, there is nothing to stop you setting it to a value...

You could try
var U; // undefined value
if( window.onscroll ===U || some_other_stuf f)
blah blah etc...

or for IE and Opera check out (and this might be more readable)

if( window.onscroll ===null)
window.onscroll =myfunction;

since under both Opera and IE the onscroll property pre-exists with the
value null. Neither of these will work under Mozilla/Netscape however,
since window.onscroll does not exist prior to being set. Hopefully this
is not a problem since you appear to be using a different script for non
IE browsers.


Thanks for the help. I think I have found another solution, using
typeof(window.o nscroll)=='unde fined'. It works in IE6, but I havn't tested
IE5 yet.
PS, checked out the site in Mozilla, the fixed headers are working fine.
On the contact page, the <legend> element is not wrapping to window or
textarea size on my monitor. You may wish to check out white-space
properties for LEGEND or LEGEND treatment under Mozilla. Cheers.


I'm aware of this, I just havn't fixed it yet. It's a case of Moz and IE
both disobeying the spec in exactly the same way! That's a turn out for
the books.

Thanks for the help.
Jul 20 '05 #2
Lasse Reichstein Nielsen wrote:
Can't exactly test what IE6 has done (window.hasOwnP roperty
is undefined) but I presume it has done something similar
since release of IE5.5.

Probably. In IE 6, the code
"undefined" in window
yields "true", so "undefined" is a property of the window object.


Where "Probably" => (p=1) :)

Thanks Lasse, there is no question I have not been using the "in"
operator. Having resolved to take on ECMA 262 as night time reading to
make up, I should post the results:

Historically Netscape failed to make "undefined" a javascript keyword,
which IHMO was a pity. In NS3, and perhaps earlier, it implemented a
window.undefine d property with attributes {dontEnum and dontDelete} to
make up for the missing keyword.

Internet Explorer 5.0 didn't implement window.undefine d so was incompatible.

ECMA 262 defines "undefined" as a global property in section 15.1.1.3.
Internet Explorer (since 5.5 presumably) and other ECMA compliant
browsers now match this standard legitamising Netscape practice. So
there is no doubt a current ECMA compliant browser should have a
non-enumerable window property "undefined" emulating an undefined
keyword, with the drawback it can be overwritten.

Dom


Jul 20 '05 #3
> Historically Netscape failed to make "undefined" a javascript keyword,
which IHMO was a pity. In NS3, and perhaps earlier, it implemented a
window.undefine d property with attributes {dontEnum and dontDelete} to
make up for the missing keyword.

Internet Explorer 5.0 didn't implement window.undefine d so was incompatible.

ECMA 262 defines "undefined" as a global property in section 15.1.1.3.
Internet Explorer (since 5.5 presumably) and other ECMA compliant
browsers now match this standard legitamising Netscape practice. So
there is no doubt a current ECMA compliant browser should have a
non-enumerable window property "undefined" emulating an undefined
keyword, with the drawback it can be overwritten.


Yup. There are a number of implementation errors in the early browsers that ECMA
cemented into the standard. Another one is

typeof null == 'object'

http://www.crockford.com/javascript/javascript.html

Jul 20 '05 #4

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

Similar topics

2
6614
by: lorinho | last post by:
Alright, I'm stumped. Per this article from Microsoft I should be able to capture the onscroll event for an iframe but for some reason it doesn't seem to be working for me... http://msdn.microsoft.com/library/en-us/dnwebteam/html/webteam02052001.asp?frame=true#scrolling Has anyone made this work successfully before?
5
20651
by: Simon Wigzell | last post by:
Looks like firefox doesn't support onscroll. Any workaround?
1
12911
by: Simon Wigzell | last post by:
Firefox has strange behaviour with onscroll. I have a sample page here: http://www.dynamicwebsitesystems.com/ScrollTest.htm If I make this the startup page for the firefox browser or launch it from Frontpage with Preview then the onscroll works - it calls the doOnScroll function and posts the alert when you move the scroll bar. It doesn't work if you go to this page from another page or if you refresh the page. What is going on here? Any...
1
3026
by: John Keers | last post by:
Can anyone tell me how to fire and use a listBox vertical onScroll event. The language I am using is C# in a windows forms application thanks
1
2511
by: Jeremy | last post by:
Is there any way to get Mozilla to fire an event when a textarea scrolls? IE seems not to have a problem with it, but Moz just won't cooperate. I tried the W3 event model: myTextArea.addEventListener("scroll", fn, true); - also tried "false" for the phase parameter (apparently this event neither bubbles nor captures). I also tried the "singleton" event model: myTextArea.onscroll = fn;
0
2146
by: Jocker | last post by:
Hi Group I'm writing an Internet Explorer plugin. Everything works well, except when I try to handle the onscroll event. http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/window2/onscroll.asp http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onscroll.asp another possibility seems to exist with IHTMLElement2.onscroll using the document body, but this does not solve the problem. the following code snippet...
0
1702
by: Jocker | last post by:
I'll try reposting this message with the hope someone can help me with this issue. PS: is this the right newsgroup for this question? --- Hi Group I'm writing an Internet Explorer plugin. Everything works well, except when I try to handle the onscroll event.
2
2169
by: Sam | last post by:
While attempting to get my floating toolbar to work in ASP.NET 2.0, I noticed that the onscroll event is not firing. I've specified this on the BODY tag, as always. After some testing, I realized that the new DocType being used in 2.0 (<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">) is the culprit. Upon using the old 1.1 DocType (<!DOCTYPE HTML PUBLIC...
0
9724
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9604
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
10379
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
9201
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
7665
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
5552
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...
1
4336
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
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.