473,378 Members | 1,369 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,378 software developers and data experts.

Javascript in netscap

Hello friends, pls tell me why this script not working in my netscap7.1
onload function is (document.layers)

function load(){
if(document.all) alert("ie");
if(document.layers) alert("ns");
}
Jul 20 '05 #1
6 1440
"Mayur" <ma********@indiatimes.com> wrote in message
news:ba**************************@posting.google.c om...
Hello friends, pls tell me why this script not working in my netscap7.1 onload function is (document.layers)

function load(){
if(document.all) alert("ie");
if(document.layers) alert("ns");
}


document.layers is not supported in that browser, use
document.getElementById instead

Please read http://jibbering.com/faq/#FAQ4_26
--
Andrew Urquhart
- FAQ: http://jibbering.com/faq
- Archive: http://groups.google.com/groups?grou...ang.javascript
- Reply: http://www.andrewu.co.uk/about/conta...ject=Re%3A+clj
Jul 20 '05 #2
On 1 Mar 2004 05:39:38 -0800, Mayur <ma********@indiatimes.com> wrote:
Hello friends, pls tell me why this script not working in my netscap7.1
Knowing what you are trying to acheive might help.
onload function is (document.layers)
(document.layers) is not a function. A more explicit example would be good.
function load(){
if(document.all) alert("ie");
Support for document.all does not indicate Internet Explorer. Opera, and
no doubt other browsers, support the collection.
if(document.layers) alert("ns");
Support for document.layers does not indicate Netscape. Netscape 7 will
evaluate the expression, typeof document.layers, to undefined.
}


Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3


function load(){
if(document.all) alert("ie");
if(document.layers) alert("ns");
}

thanks for reply.

I have 5 div in my page and I want to identify all as array
(document.layers)
and want to do something on it.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4
Mayur Vyas wrote:

function load(){
if(document.all) alert("ie");
if(document.layers) alert("ns");
}

thanks for reply.

I have 5 div in my page and I want to identify all as array
(document.layers)
and want to do something on it.


Did you bother reading the FAQ that was linked to?

Netscape 7 does *not* support document.layers nor does it support
document.all

And on top of that, your test is utterly useless at identifying ie and
ns, as there are a lot more browsers that support document.all than ie
and more browsers that support document.layers than ns. There is even a
browser that supports *both* of them so you would get both alerts. And
not all versions of NS (6 and 7) support document.layers, they use
document.getElementById as do most modern browsers. (I would say all
modern browsers but as soon as I do someone will come up with one that
doesn't)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 20 '05 #5
On 02 Mar 2004 04:58:18 GMT, Mayur Vyas <ma*******@yahoo.com> wrote:
I have 5 div in my page and I want to identify all as array
(document.layers)
and want to do something on it.

You can't - did you miss where you were told that already?
"Documenrt.all" is a Microsoft extension (that happens to be managed
by a lot more than MSIE - so is no good at all as a browser test)
whereas "document.layers" is an EARLY Netscape extension that works on
more than just Netscape (but doesn't work on modern Netscape).

You really, really do have to use "document.GetElementById ("id") - as
you were told earlier/
Jul 20 '05 #6
Mayur Vyas wrote:
[...]
I have 5 div in my page and I want to identify all as array
(document.layers) and want to do something on it.


With proper quoting[1], you could have noticed that there is no
"document.layers" object in the Gecko DOM. You can, however,
use a method of the W3C DOM to refer to the collection of
"HTMLDivElement" objects:

document.getElementsByTagName("div")

Similar to an Array object, an HTMLCollection object allows to
access its elements through their zero-based index as properties
of the object. Unlike an Array object, it also allows to access
its elements through the name and/or ID of the element object,
if set.

Note that the above method is not supported in all
DOMs, so you should test for it before using it:
<http://pointedears.de.vu/scripts/test/whatami>
PointedEars
___________
[1] <http://www.netmeister.org/news/learn2quote.html>
Jul 23 '05 #7

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

Similar topics

2
by: msnews.microsoft.com | last post by:
Hi Every Body, I have build the website in asp.net using vb.net. I use the asp.net validation controls for client side validation. When I run the site in Internet Explorer, It run properly and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.