473,750 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CSIEStyl error

This function of [inherited] javascript is producing errors

function CSIEStyl(s) { return document.all.ta gs("div")[s].style; }

On inspection document.all doesn't have a 'tags' hanging off it.
The function [CSIEStyl] which seems to be prolific [over
5000 hits on Google.

The context where it's causing an error is this:

CSIEStyl(s).vis ibility=(v==0)? "hidden":"visib le";

Where s is mossroster

The only place I can find that text in the page is here:

<csaction name="61c7ee54" class="ShowHide " type="onevent" val0="mossroste r"
val1="1"></csaction>
<csaction name="805c60" class="ShowHide " type="onevent" val0="mossroste r"
val1="1"></csaction>

and here

CSAct[/CMP/ '61c7ee54'] = new Array(CSShowHid e,/CMP/ 'mossroster',1) ;
CSAct[/CMP/ '805c60'] = new Array(CSShowHid e,/CMP/ 'mossroster',1) ;

However, I have no idea what these lines refer to. Esp. the use of CMP??

Any help greatly appreciated!
--
==============
Not a pedant
==============

Mar 6 '06 #1
7 1257
pemo wrote:
This function of [inherited] javascript is producing errors

function CSIEStyl(s) { return document.all.ta gs("div")[s].style; } ^^ On inspection document.all doesn't have a 'tags' hanging off it.
The name is program here. The above is IE-proprietary. document.all is now
supported by other UAs as well, however, its properties are not equally
supported. Have a preference for standards compliant DOM access instead:

function isMethodType(s)
{
return (s == "function" || s == "object");
}

function CSStyl(s)
{
var coll;

if (isMethodType(t ypeof document.getEle mentsByTagName)
&& document.getEle mentsByTagName)
{
coll = document.getEle mentsByTagName( "div");
}

// required for IE < 5
else if (typeof document.all != "undefined"
&& isMethodType(do cument.all.tags )
&& document.all.ta gs)
{
coll = document.all.ta gs("div");
}

if (coll && coll[s])
{
return coll[s].style;
}

return null;
}
The function [CSIEStyl] which seems to be prolific [over
5000 hits on Google.
It is a sad truth that bad code is often wider distributed than good one.
IE-based UAs compared to Gecko-based UAs, for example.
The context where it's causing an error is this:

CSIEStyl(s).vis ibility=(v==0)? "hidden":"visib le";
What do you expect? The referencing itself is error-prone.
It should be at least

var o;
if ((o = CSIEStyl(s)))
{
o.visibility = v ? "visible": "hidden";
}

Note that if we assume `x' is numeric or boolean,

(x == 0) ? true_value : false_value
(x == false) ? true_value : false_value

is (due to implicit type conversion) semantically equal to

x ? false_value : true_value

(0 == false).
Where s is mossroster

The only place I can find that text in the page is here:

<csaction name="61c7ee54" class="ShowHide " type="onevent" val0="mossroste r" val1="1"></csaction>
<csaction name="805c60" class="ShowHide " type="onevent" val0="mossroste r"
val1="1"></csaction>
There is no such element as `csaction' in HTML or XHTML. Apparently this
is generator code. Google tells that it is used by Adobe GoLive
(CyberStudio; hence the "cs") for "JavaScript Actions". What Adobe calls
that "proprietar y GoLive HTML code elements" that "can be stripped during
FTP upload or export of the page.", I call it not Valid HTML. Probably
if the option is not used to strip those elements during FTP upload (which
would most certainly have to be performed with GoLive), or when the "page"
is "exported", , one will end up with that invalid markup.

<URL:http://www.adobe.com/products/golive/pdfs/gl_whtpr_js.pdf >
and here

CSAct[/CMP/ '61c7ee54'] = new Array(CSShowHid e,/CMP/ 'mossroster',1) ;
CSAct[/CMP/ '805c60'] = new Array(CSShowHid e,/CMP/ 'mossroster',1) ;

However, I have no idea what these lines refer to. Esp. the use of CMP??
This is syntactically incorrect ECMAScript code:

| Error: missing ] in index expression
| Source file: javascript:CSAc t[/CMP/ '61c7ee54'] = new
| Array(CSShowHid e,/CMP/ 'mossroster',1) ;
| Line: 1, Column: 12
| Source code:
| CSAct[/CMP/ '61c7ee54'] = new Array(CSShowHid e,/CMP/ 'mossroster',1) ;
| --------------^

Most certainly it is generator code as well. Watch for what the client
gets instead (View Source).
-- ^ ==============
Not a pedant
==============


But someone who is not able to delimit his signature properly, due to his
flawed newsreader. <URL:http://insideoe.com/>
PointedEars
Mar 6 '06 #2
Thomas 'PointedEars' Lahn said the following on 3/6/2006 2:32 PM:
pemo wrote:
This function of [inherited] javascript is producing errors

function CSIEStyl(s) { return document.all.ta gs("div")[s].style; }

^^
On inspection document.all doesn't have a 'tags' hanging off it.


The name is program here. The above is IE-proprietary. document.all is now
supported by other UAs as well, however, its properties are not equally
supported. Have a preference for standards compliant DOM access instead:

function isMethodType(s)
{
return (s == "function" || s == "object");
}

function CSStyl(s)
{
var coll;

if (isMethodType(t ypeof document.getEle mentsByTagName)
&& document.getEle mentsByTagName)


The second half of that if test seems to be superfluous and not needed.

if isMethodType( returns true then document.getEle mentsByTagName will
always be true.

if isMethodType( returns false then document.getEle mentsByTagName
existence is irrelevant and the second test is not needed.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 6 '06 #3
VK

Randy Webb wrote:
if (isMethodType(t ypeof document.getEle mentsByTagName)
&& document.getEle mentsByTagName)


The second half of that if test seems to be superfluous and not needed.

if isMethodType( returns true then document.getEle mentsByTagName will
always be true.

if isMethodType( returns false then document.getEle mentsByTagName
existence is irrelevant and the second test is not needed.


I missed the beginning of the discussion so I'm not sure what
isMethodType checking for. I hope it takes both "function" and "object"
as valid (true), otherwise it will fail on IE.

In IE all methods of window and document objects reported as 'object',
while in Firefox as 'function'.

Mar 6 '06 #4
VK wrote:
Randy Webb wrote:
> if (isMethodType(t ypeof document.getEle mentsByTagName)
> && document.getEle mentsByTagName)
The second half of that if test seems to be superfluous and not needed.

if isMethodType( returns true then document.getEle mentsByTagName will
always be true.

if isMethodType( returns false then document.getEle mentsByTagName
existence is irrelevant and the second test is not needed.


I missed the beginning of the discussion so I'm not sure what
isMethodType checking for.


Google Groups, which you use, shows the complete discussion always,
except postings with "X-No-Archive: Yes" header.
I hope it takes both "function" and "object" as valid (true), [...]


It does. Therefore, the second half is not superfluous, and it is
needed; the property value could be `null' and typeof null == "object".
PointedEars
Mar 6 '06 #5
Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 3/6/2006 2:32 PM:
pemo wrote:
This function of [inherited] javascript is producing errors

function CSIEStyl(s) { return document.all.ta gs("div")[s].style; }


^^
On inspection document.all doesn't have a 'tags' hanging off it.

The name is program here. The above is IE-proprietary. document.all
is now
supported by other UAs as well, however, its properties are not equally
supported. Have a preference for standards compliant DOM access instead:

function isMethodType(s)
{
return (s == "function" || s == "object");
}

function CSStyl(s)
{
var coll;

if (isMethodType(t ypeof document.getEle mentsByTagName)
&& document.getEle mentsByTagName)

The second half of that if test seems to be superfluous and not needed.

if isMethodType( returns true then document.getEle mentsByTagName will
always be true.

if isMethodType( returns false then document.getEle mentsByTagName
existence is irrelevant and the second test is not needed.


Not sure where to join the thread here...
Shouldn't the 'typeof' operator be inside isMethodType? Then it can be:

function isMethodType(s)
{
return (null != s && ("function"==ty peof s || "object"==typeo f s));
}

and called with:

isMethodType(do cument.getEleme ntsByTagName)
But it seems pretty pointless anyway, isMethodType will return true for
any non-null object. The usefulness of the 'function' test is
completely subverted by the - || object - bit.

Something like isMethodType is only seems relevant in a situation where
you are contributing to shared libraries and you don't know what anyone
else is doing. But a fundamental principle in such situations is
usually to not overwrite native or DOM standard methods - so given the
weakness of the test, what's the point?

Can it be made more robust?
--
Rob
Mar 7 '06 #6
RobG wrote:
Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 3/6/2006 2:32 PM:
function isMethodType(s)
{
return (s == "function" || s == "object");
}

function CSStyl(s)
{
var coll;

if (isMethodType(t ypeof document.getEle mentsByTagName)
&& document.getEle mentsByTagName)

The second half of that if test seems to be superfluous and not needed.
Again, this could not be farther from the truth.
if isMethodType( returns true then document.getEle mentsByTagName will
always be true.

if isMethodType( returns false then document.getEle mentsByTagName
existence is irrelevant and the second test is not needed.


[...]
Shouldn't the 'typeof' operator be inside isMethodType?


No, it should not.
Then it can be:

function isMethodType(s)
{
return (null != s && ("function"==ty peof s || "object"==typeo f s));
}

and called with:

isMethodType(do cument.getEleme ntsByTagName)
And if `document' is not defined, a ReferenceError exception would be
thrown. I have designed that method (included in types.js) as a general
solution for the [[Call]] problem. It is as it is for a reason, you know.
But it seems pretty pointless anyway, isMethodType will return true for
any non-null object.
Works as designed.
The usefulness of the 'function' test is completely subverted by the -
|| object - bit.
It is not.
Something like isMethodType is only seems relevant in a situation where
you are contributing to shared libraries and you don't know what anyone
else is doing.
No, it is relevant for _all_ feature tests. Only for DOM feature tests
you will have to add the additional type-converting test if you want to
support IE.
But a fundamental principle in such situations is usually to not overwrite
native or DOM standard methods - so given the weakness of the test, what's
the point?
The point is that you can determine reliably enough if something can be
called or not.
Can it be made more robust?


There is already isMethod() which can take a string argument and uses eval()
then (which appears to me to be the only way to avoid early evaluation),
but it breaks for null base objects. I have been working on it to handle
that, too, for some time now.
PointedEars
Mar 7 '06 #7
Thomas 'PointedEars' Lahn wrote:
RobG wrote:

Randy Webb wrote: [...]
The second half of that if test seems to be superfluous and not needed.

Again, this could not be farther from the truth.
I'm sure Randy appreciated being told your view again.
[...]Shouldn't the 'typeof' operator be inside isMethodType?


No, it should not.

[...] And if `document' is not defined, a ReferenceError exception would be
thrown. I have designed that method (included in types.js) as a general
solution for the [[Call]] problem. It is as it is for a reason, you know.


Hence why I was asking, you know.

But it seems pretty pointless anyway, isMethodType will return true for
any non-null object.


Works as designed.


Without being given the original design, it is difficult for anyone else
to determine that. And without knowing precisely what it is designed to
do (or not), I am uncertain as to its suitability to various situations.

Hence the questions...

The usefulness of the 'function' test is completely subverted by the -
|| object - bit.


It is not.

Something like isMethodType is only seems relevant in a situation where
you are contributing to shared libraries and you don't know what anyone
else is doing.

No, it is relevant for _all_ feature tests. Only for DOM feature tests
you will have to add the additional type-converting test if you want to
support IE.

But a fundamental principle in such situations is usually to not overwrite
native or DOM standard methods - so given the weakness of the test, what's
the point?

The point is that you can determine reliably enough if something can be
called or not.


'reliably enough' - it is the extent of that reliability that I'd like
to understand clearly. As far as I can tell, all browsers work OK when
dealing with native JavaScript objects when test as follows:

alert( typeof Math.floor ) // shows 'function'
It's when DOM objects are involved that some brosers (e.g. IE) lose the
plot. When allowances are made for these browsers, the tests are weakened.

For example, testing whether typeof document.getEle mentById returns
'function' seems pretty definitive, but just testing that it's an object
and not null seems a bit soft.

That is not to say that therefore there shouldn't be any testing at all,
only that if the test is weak, can a methodology be employed that
removes the need for such tests and provides the same level of
reliability? Or a better test be devised?

Another aspect is how to determine an appropriate test for the platform
the code is running on. What feature test will tell you if typeof
function is supported for all objects?

For example, in Gecko you can look at a DOM object's constructor:

var x = document.getEle mentById;
if ( Function == x.constructor ) // returns true

but in IE x.constructor is undefined - which seems to hold true for all
DOM objects in IE. But IE does have a constructor property for native
JavaScript objects, why not with DOM objects and methods? (that's a
rhetorical question... :-) ).

An idea is to use toString(). IE seems to have 'undetectable' support
for toString with DOM objects, you can't call it explicitly:

e.g.

var x = document.getEle mentById;
alert( x ) // shows function getElementById () {...}
which looks like the result of x.toString(), but

alert( x.toString() ) // shows undefined
alert( typeof x.toString ) // shows undefined
What the...?

Can it be made more robust?

There is already isMethod() which can take a string argument and uses eval()
then (which appears to me to be the only way to avoid early evaluation),
but it breaks for null base objects. I have been working on it to handle
that, too, for some time now.


This one?

function isMethod(o)
{
if (typeof o == "string")
{
o = eval(o);
}

var t;
return ((t = typeof o) == "function" || t == "object" && o);
}
Have you considered two functions, one for native JavaScript objects and
one for DOM? e.g.:

function testMethodNativ e (o)
{
return ('function' == typeof o);
}

or

function testMethodNativ e (o)
{
return (Function == o.constructor);
}

Both seem to work fine with native objects like Math.floor, Array.join
and String.split. The following can be used to test DOM objects:
function testMethodDOM (o)
{
if ('function' == typeof document.write) {

// Supports typeof function for DOM objects
return ('function' == typeof o);

} else {

// Weaker test for others
return ('object' == typeof o && null != o);
}
}

Or maybe they can be combined, similar to the typical test for
document.getEle mentById/document.all.

OK, testing document.write is not much better than the olde worlde
assumption that support for document.all means IE, but 'it works'. Is
it any less robust than isMethod or isMethodType? Any UA that doesn't
support document.write is likely not of much use anyway (the use of
document.write is not restricted to visual UAs and should be implemented
by any UA that supports scripting at all).

At least this way users of browsers with decent support for DOM objects
get the added protection of better feature testing, they aren't
penalised by weaker tests that allow for other browsers. This seems to
fit with the principle of graceful degradation.

Maybe a toString test can be included too (allowing for IE's
non-detectability/non-call-ability for toString with DOM objects).

function isMethod(o)
{
return /function /.test(o);
}

Here a better test would be:

return /^function /.test(o);
but IE barfs on that.

--
Rob
Mar 7 '06 #8

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

Similar topics

2
4379
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two files containing some templates: adjacency_list.hpp and mem_fn.hpp can not compile. Does anyone have any solutions?
5
16254
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information Server might not be running or the path exists and is redirected to another machine. Please check the status of this virtual directory in the Internet Services Manager."
1
8415
by: Aravind | last post by:
we have two files: 1. rc4.c (defines one function "create_pin()") 2. MyImpl.c(calling the function "create_pin()"),This implements JNI method. 1.When I am trying to create .dll file with one file rc4.obj(rc4.c),it is creating the .dll file without any error. Command : ILINK32 rc4.obj 2.But,when we are trying to create .dll file with two .obj files with following errors.
1
6409
by: yanwan | last post by:
I met this problem in executing a c++ project in visual studio. Does anyone have suggestions to resolve "error lnk 2001"? --------------------Configuration: reconstruction - Win32 Debug-------------------- Linking... icarus_camera.obj : error LNK2001: unresolved external symbol _dgels_ icarus_leastsquares.obj : error LNK2001: unresolved external symbol _dgels_ icarus_maths.obj : error LNK2001: unresolved external symbol _dgels_...
5
5716
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ================================================================= Error 19: "CORBAManagerMessages.h", line 4 # Unexpected 'std'. using std::string; ^^^
13
6611
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
5019
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying. I created the websetup and built the MSI, have the bundled version. Copied to webserver and ran Websetup.msi. Said I had to remove old version, which I did, then reran WebSetup.msi and keeps giving me this error. "The installer was interrupted...
2
19485
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
8838
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
9396
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
9342
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
9256
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
8263
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...
0
4716
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
3323
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
2807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2226
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.