473,608 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

browsers & standards

I'm told the standards way of referencing page content is
document.getEle mentById()

What is the lowest version of each browser type with which this will
work?

Thank you

Nov 6 '05 #1
24 1802
ab**********@ya hoo.com said the following on 11/6/2005 4:54 PM:
I'm told the standards way of referencing page content is
document.getEle mentById()

What is the lowest version of each browser type with which this will
work?


The lowest version that will support it is the lowest version that will
pass this test:

if (document.getEl ementById)

Meaning, you do object/feature detection and it doesn't matter.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 6 '05 #2
ab**********@ya hoo.com wrote:
I'm told the standards way of referencing page content is
document.getEle mentById()

What is the lowest version of each browser type with which this will
work?


Even the most recent browsers may not support it. You need to test for it

if(document.get ElementById){// do stuff with document.getEle mentById()}

Mick
Nov 6 '05 #3
ab**********@ya hoo.com wrote:
I'm told the standards way of referencing page content is
document.getEle mentById()

What is the lowest version of each browser type with which this will
work?


General advice is that getElementById is supported by most browsers that
emerged *after* Netscape 4 and IE 4. Nearly all browsers that have been
released in the last few years support it - it's more widely supported
than document.all and document.layers is pretty much dead.

But take heed of Randy & Mick's advice: just because a browser is new or
supports JavaScript does not mean it supports any particular method or
interface, which seems to be particularly true of mobile browsers.
Feature detection and graceful fall-back is always required.

There are other ways of getting references to elements that may be more
appropriate depending on the circumstance such as the links, images and
forms collections or traversing the DOM (parent & child nodes, siblings,
etc.).
--
Rob
Nov 7 '05 #4
ab**********@ya hoo.com a écrit :
I'm told the standards way of referencing page content is
document.getEle mentById()

What is the lowest version of each browser type with which this will
work?


These references answer all your questions and more:

Using Web Standards in Your Web Pages
http://www.mozilla.org/docs/web-deve...upgrade_2.html

Accessing Elements with the W3C DOM:
http://www.mozilla.org/docs/web-deve...tml#dom_access

Gérard
--
remove blah to email me
Nov 7 '05 #5
JRS: In article <Wt************ ********@comcas t.com>, dated Sun, 6 Nov
2005 17:03:37, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
ab**********@y ahoo.com said the following on 11/6/2005 4:54 PM:
I'm told the standards way of referencing page content is
document.getEle mentById()

What is the lowest version of each browser type with which this will
work?


The lowest version that will support it is the lowest version that will
pass this test:

if (document.getEl ementById)

Meaning, you do object/feature detection and it doesn't matter.


One may not be able to do object/feature detection.

It can be used in javascript so that the javascript knows whether to use
the native method or to use some emulation.

It cannot be used in a code review meeting when Big Boss asks "What is
the lowest version of each browser type with which this code will work?"
unless each browser type, in all versions, and the time to do the tests,
are available at the meeting.

One should always consider the actual meaning of the question asked;
and, if possible, answer that in addition to answering the question as
it *might* better have been asked.

If the answer is equivalent to "all browser releases since 1999/01/01,
and some earlier", and Big Boss has a Policy of ignoring all twentieth-
century browsers, then the answer to Big Boss's question could be "Don't
know, Sir; but I do know that it works with all that, according to
Policy, it needs to work with, Sir.".

I expect that your test process will be perfectly satisfactory in code
for getElementById; but it will not be entirely satisfactory for
toFixed, since for that it is known (FAQ 4.6) that "works right" is a
subset of "exists".

<FAQENTRY> to enable sound feature detection on toFixed, ISTM that the
FAQ should indicate a test value that can be used to prove toFixed to be
good, or at least to have no known error. 0.77.toFixed(0) may be such a
test, or a part thereof.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of 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.
Nov 7 '05 #6
Dr John Stockton said the following on 11/7/2005 8:48 AM:
JRS: In article <Wt************ ********@comcas t.com>, dated Sun, 6 Nov
2005 17:03:37, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
ab**********@ yahoo.com said the following on 11/6/2005 4:54 PM:
I'm told the standards way of referencing page content is
document.get ElementById()

What is the lowest version of each browser type with which this will
work?
The lowest version that will support it is the lowest version that will
pass this test:

if (document.getEl ementById)

Meaning, you do object/feature detection and it doesn't matter.

One may not be able to do object/feature detection.


Example of not being able to object/feature detect? I know you can't
test for try/catch but I am unaware of anywhere that you can not
object/feature detect document.getEle mentById even if it is emulated.
And in order to emulate it, you *must* be able to understand the
emulation, and in understanding it, the OQ would never have been asked.
It can be used in javascript so that the javascript knows whether to use
the native method or to use some emulation.
And again, it order to be able to emulate it, you would have to know the
alternatives to it and be able to write that emulation. If you can
emulate it, you don't have to ask where it is supported. And even then,
you do not *ever* need to know the browser version to determine it.
It cannot be used in a code review meeting when Big Boss asks "What is
the lowest version of each browser type with which this code will work?"
unless each browser type, in all versions, and the time to do the tests,
are available at the meeting.
"Big Boss, that question can not be answered truthfully, but I can
programatically determine if a browser supports it, without errors in
the code if it doesn't".

Either Big Boss will understand that, or, s/he wouldn't know if you were
lying even if you weren't.
One should always consider the actual meaning of the question asked;
and, if possible, answer that in addition to answering the question as
it *might* better have been asked.
IE4, with an updated JS engine, supports gEBI. It is not the browser
version but rather the scripting engine that determines support or lack
thereof.
If the answer is equivalent to "all browser releases since 1999/01/01,
and some earlier", and Big Boss has a Policy of ignoring all twentieth-
century browsers, then the answer to Big Boss's question could be "Don't
know, Sir; but I do know that it works with all that, according to
Policy, it needs to work with, Sir.".
If Big Boss has enough sense/knowledge to ask the question in the first
place, he should have enough sense/knowledge to know the answer, or
where to find it. Your example is lacking.
I expect that your test process will be perfectly satisfactory in code
for getElementById; but it will not be entirely satisfactory for
toFixed, since for that it is known (FAQ 4.6) that "works right" is a
subset of "exists".
Yes, and that is why it is in the FAQ. But since I don't use, and have
no need, for toFixed, it doesn't matter to me.
<FAQENTRY> to enable sound feature detection on toFixed, ISTM that the
FAQ should indicate a test value that can be used to prove toFixed to be
good, or at least to have no known error. 0.77.toFixed(0) may be such a
test, or a part thereof.


The thread started just yesterday about FAQ Updates would have been a
better place for that. It would have gotten immediate attention and it
has *nothing* to do with this thread.

Second, since toFixed is known to be buggy, and it has a prototype
solution, the best solution to that problem is not to test for but
rather to simply prototype anyway and then you don't have to worry about
it anymore. Besides, it would execute faster without the testing.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 7 '05 #7
Dr John Stockton wrote:
One may not be able to do object/feature detection.
...
<FAQENTRY> to enable sound feature detection on toFixed, ISTM that the
FAQ should indicate a test value that can be used to prove toFixed to
be good, or at least to have no known error. 0.77.toFixed(0) may be
such a test, or a part thereof.


I think most people understand that feature detection can only decide if
features are available. There is, of course, no way to determine if a
feature behaves according to standards or expectations. This is definitely a
limitation of the "feature detection" strategy. In some cases, in addition
to using feature detection, it can be required to do browser detection to
sort through quirks in implementations of features in specific browsers.

IMO, though, if a browser implements a feature but does so incorrectly, and
the user sees an error, that doesn't bother me. If a browser has bugs, the
user should either live with it, upgrade, or pick a different browser. The
only exception, unfortunately, is IE. It has bugs and quirks, but it's so
widely used that they almost certainly need to be taken into consideration.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 8 '05 #8
Matt Kruse wrote:
Dr John Stockton wrote:
One may not be able to do object/feature detection.
...
<FAQENTRY> to enable sound feature detection on toFixed, ISTM that the
FAQ should indicate a test value that can be used to prove toFixed to
be good, or at least to have no known error. 0.77.toFixed(0) may be
such a test, or a part thereof.


I think most people understand that feature detection can only decide if
features are available. There is, of course, no way to determine if a
feature behaves according to standards or expectations.


That assumption is not generally true and it does not apply here.
One can test if Number objects have the toFixed() method and one
can test if it returns the expected result on a selected fixed
number before applying it to a variable.
PointedEars
Nov 8 '05 #9
Thomas 'PointedEars' Lahn said the following on 11/8/2005 2:51 PM:
Matt Kruse wrote:

Dr John Stockton wrote:
One may not be able to do object/feature detection.
...
<FAQENTRY> to enable sound feature detection on toFixed, ISTM that the
FAQ should indicate a test value that can be used to prove toFixed to
be good, or at least to have no known error. 0.77.toFixed(0) may be
such a test, or a part thereof.


I think most people understand that feature detection can only decide if
features are available. There is, of course, no way to determine if a
feature behaves according to standards or expectations.

That assumption is not generally true and it does not apply here.
One can test if Number objects have the toFixed() method and one
can test if it returns the expected result on a selected fixed
number before applying it to a variable.


But that still won't guarantee that it will work in all instances.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 8 '05 #10

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

Similar topics

12
1707
by: code_wrong | last post by:
Hi, as the subject says How many browsers must we support? How many are there exactly? When I run this JavaScript in Firefox and IE6: function init(){ if(document.getElementById) alert("W3C DOM Supported"); else if(document.all)
133
6843
by: Alan Silver | last post by:
Hello, Just wondered what range of browsers, versions and OSs people are using to test pages. Also, since I don't have access to a Mac, will I have problems not being able to test on any Mac browsers, or is there some other way of checking? TIA --
17
2302
by: Dudely | last post by:
My web page displays just fine under IE7, but under IE6 about 90% of it is just plain missing. I get the top of the page, and the bottom of the page... but not the middle. I have not tested with any other browsers. The page is at www.greengoldcapital.com I use considerable amounts of CSS, and a lot of other things including javascript, SSI, PHP, mySQL, and a partridge in a pear tree. I have a third party application integrated in,...
0
8003
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
8478
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...
1
8152
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
8341
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...
0
6817
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
6014
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
4025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1598
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1331
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.