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

How do I make this work for W3C?

What do I put for the W3C part of this code?

function dot(i)
{
this.X = Xpos;
this.Y = Ypos;
this.dx = 0;
this.dy = 0;
if (isNetscape4) {
this.obj = eval("document.dot" + i);
} else if (isIE) {
this.obj = eval("dot" + i + ".style");
} else if (isW3C) {
this.obj = ?????????????
}
}

var dots = new Array(nDots);
var i = 0;
for (i = 0; i < nDots; i++) {
dots[i] = new dot(i);
}
Jul 23 '05 #1
2 1137
"David W. Deley" <de****@gte.net> writes:
What do I put for the W3C part of this code?
Code is *not* obvious, especially without comments. That means
we have to guess what you want the code to do.
function dot(i)
{
this.X = Xpos;
this.Y = Ypos;
this.dx = 0;
this.dy = 0;
if (isNetscape4) {
Any browser detection almost almways have failures. Trying to detect
Netscape 4 is not as efficient as detecting the absence of better
approaches and testing for the success of this one.
this.obj = eval("document.dot" + i);
Never use eval to access properties. Never! (With overwhelming
probability, you'll never need to use eval at all, since there are
safer and more efficient alternatives to all the common (mis)uses of
eval).
} else if (isIE) {
this.obj = eval("dot" + i + ".style");
} else if (isW3C) {
this.obj = ?????????????
I assume that you are trying to find an element with, e.g., id="dot2".

I recommned this approach:
---
var id = "dot"+i;
if (document.getElementById) {
this.obj = document.getElementById(id);
} else if (document.all) {
this.obj = document.all[id];
} else if (document[id]) {
this.obj = document[id];
}
---
No browser detection. Testing for known access methods first and
falling back on less standardized methods. If a browser has both
document.getElementById and document.layers, it will use the standard
method (yes, such browsers exist, and would be likely to be
misidentified as Neetscape 4).
dots[i] = new dot(i);


Traditionally, functions used as constructors are capitalized, so
I would change "dot" to "Dot".

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
Fabulous. That should work great. Thank you. (I'm modifying code
someone else wrote.) -D.D.

Lasse Reichstein Nielsen wrote:

"David W. Deley" <de****@gte.net> writes:
What do I put for the W3C part of this code?


Code is *not* obvious, especially without comments. That means
we have to guess what you want the code to do.
function dot(i)
{
this.X = Xpos;
this.Y = Ypos;
this.dx = 0;
this.dy = 0;
if (isNetscape4) {


Any browser detection almost almways have failures. Trying to detect
Netscape 4 is not as efficient as detecting the absence of better
approaches and testing for the success of this one.
this.obj = eval("document.dot" + i);


Never use eval to access properties. Never! (With overwhelming
probability, you'll never need to use eval at all, since there are
safer and more efficient alternatives to all the common (mis)uses of
eval).
} else if (isIE) {
this.obj = eval("dot" + i + ".style");
} else if (isW3C) {
this.obj = ?????????????


I assume that you are trying to find an element with, e.g., id="dot2".

I recommned this approach:
---
var id = "dot"+i;
if (document.getElementById) {
this.obj = document.getElementById(id);
} else if (document.all) {
this.obj = document.all[id];
} else if (document[id]) {
this.obj = document[id];
}
---
No browser detection. Testing for known access methods first and
falling back on less standardized methods. If a browser has both
document.getElementById and document.layers, it will use the standard
method (yes, such browsers exist, and would be likely to be
misidentified as Neetscape 4).
dots[i] = new dot(i);


Traditionally, functions used as constructors are capitalized, so
I would change "dot" to "Dot".

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'

Jul 23 '05 #3

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

Similar topics

2
by: Venkat | last post by:
Hi, My HTML page doesnot work properly in Netscape 7.1. But works fine in Opera 7 and IE 6.0. I could not figure out the problem. If any one could/suggest it would be nice.. This piece of HTML...
2
by: Andrew Mogford | last post by:
Hi, We have moved a web site from a development server running Windows 2000 and IIS 5 to a Windows 2003 server running IIS 6.0 Now the asp pages do not work correctly. For example,...
0
by: Jarod_24 | last post by:
How does tabindex work in ASP .net pages I dosen't seem to work quite like in regular forms. and there isn't any TabStop property either. 1 .How do you prevent a control form beign "tabbed"....
30
by: bblais | last post by:
Hello, Let me start by saying that I am coming from a background using Matlab (or Octave), and C++. I am going to outline the basic nuts-and-bolts of how I work in these languages, and ask for...
4
by: rodchar | last post by:
hey all, i working with the Publisher object model in an ASP.NET page. When I'm working with my project locally everything works fine. However, when I deploy the application to my app server, it...
9
by: Cliff | last post by:
I've got a number of SNMP devices scattered around the globe that I want to get some information off.. I've got a couple of classes whcih get a quite complex table together from SQL and SNMP...
3
by: hscott93 | last post by:
Hello. I have a new Vista based laptop at work that connects to a Windows 2003 Small Business Server at work via an assigned, static IP address. When I take the laptop home, I have router that...
2
by: gsherp | last post by:
I can get the Onclick event handler to work when I added a new row using insertRow. It doesn't work in IE or in FF var cellarea = row.insertCell(2); cellarea.style.backgroundColor =...
0
by: wimdows | last post by:
Hi, I've successfully added custom fields to the Task Work Item template, using the Process Editor (and opening from server). However, I would like to also see these items in the field list...
1
by: FlashT | last post by:
Hello, I got a script: http://www.mattkruse.com/javascript/autocomplete/index.html It works fine on IE and Opera, but does not on FF. It does something on FF, but not what it should do (check...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.