Re: Issue Getting Suckerfish Dropdown Menu Working in IE6



Ste wrote:
I'm having a few issues getting a 'Son of Suckerfish' dropdown menu
working in IE6 so am just posting here for some help please.

Here's the article I was using:
http://www.htmldog.com/articles/suckerfish/dropdowns/

And here's the exact example my menu is derived from:
http://www.htmldog.com/articles/suckerfish/dropdowns/example/
[...]
<script type="text/javascript"><!--//--><![CDATA[//><!--

This is madness. I know the explanation for it, but that is inherently
flawed: there is no working HTML user agent that displays `script' element
content, so nothing needs to be commented out. Especially not when that
`script' element is placed within the `head' element.

The `script' element is supported since HTML 3.2, which is by definition
a snapshot of current practice at the time of publication (1997-01-14),
and HTML 2.0-only user agents went out of fashion long ago, with HTML 2.0
eventually being obsoleted by RFC2854 in June 2000.

And XHTML should not be served to HTML user agents.

sfHover = function() {

sfHover should be declared as a variable:

var sfHover = ...

var sfEls = document.getElementById("nav2").getElementsByTagName("LI");

This requires support for the Web standards W3C DOM Level 2 Core and HTML.

for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {

This requires support for a proprietary property on a host object.

this.className+=" sfhover";

This renders the `class' attribute value to be of an unwise format if it did
not contain a CSS class name before.

http://www.w3.org/TR/html4/struct/global.html#adef-class
http://www.w3.org/TR/html4/types.html#type-cdata

}
sfEls[i].onmouseout=function() {

This also requires support for a proprietary property on a host object.

this.className=this.className.replace(new RegExp(" sfhover\\b"), "");

Using the RegExp constructor is unnecessary here. Due to DOM history, the
user agents that would not support Regular Expression literals instead would
also not support the `className' property.

http://PointedEars.de/scripts/es-matrix

The Regular Expression used also is not compliant to CSS 2(.1), which
allows characters outside the range [a-zA-Z0-9_] to be contained in CSS
class identifiers:

http://www.w3.org/TR/CSS21/grammar.html#grammar

But those characters would be recognized as word delimiters by \b, see
ECMA-262 Ed. 3, 15.10.2.6.

}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

if (/\b(function|object)\b/i.test(typeof document.body.attachEvent)
&& document.body.attachEvent)

would be a much better feature test.

The Suckerfish approach also ignores that the `mouseover' and the `mouseout'
events bubble in all common DOMs, including the MSHTML DOM. So generally
the following is possible, with using much less dependencies on both
proprietary properties and W3C DOM methods:

<head>
...
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function handleMouseEvent(e)
{
var t = e.target || e.srcElement;
if (/li/i.test(t.tagName))
{
switch (e.type)
{
case "mouseover":
t.className += (!t.className ? "" : " ") + "sfhover";
break;

case "mouseout":
t.className = this.className.replace(
/(\S\s+)?sfhover(\s+\S)?/, "$1$2");
break;
}
}
}
</script>
</head>

<body>
<ul
onmouseover="if (typeof event != "undefined") handleMouseEvent(event);"
onmouseout="if (typeof event != "undefined") handleMouseEvent(event);"
>
...
</ul>
...
</body>

//--><!]]></script>

This is madness, too.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
.



Relevant Pages

  • Re: iscontenteditable browser support
    ... but am having trouble finding data on browser support. ... HTML edited using Firefox will have wildly different markup then HTML edited using Safari or Internet Explorer. ... If you take a look at most webbased WYSIWYG html editors, those that support it use a variety of hacks, most involve adding font tags and then replace those using DOM methods. ...
    (comp.lang.javascript)
  • Re: this.form object
    ... mike wrote: ... > I have html like: ... connection between link and form in the DOM. ... as a proprietary property of its DOM, ...
    (comp.lang.javascript)
  • Re: InnerHTML question
    ... support XHTML at some point in the future. ... tag-soup HTML in the guise of XHTML is letting people authoring ... which case the HTML DOM scripts will mostly fail if it is served as ... Web applications that support both will go ...
    (comp.lang.javascript)
  • Re: can some1 help with my kink is java
    ... And the differences between those two types of DOM (by ... We have the HTML DOM, with its case insensitivity, historical ... While the XHTML DOM is case sensitive, ... scripting one DOM is likely to get in the way when scripting the other. ...
    (comp.lang.javascript)
  • Re: calling a function from a iframe
    ... The aspect of HTML validity that is significant is ... When presented with structurally invalid HTML browsers engage in 'error ... Structurally valid HTML mark-up has a tree-like structure, the DOM also ...
    (comp.lang.javascript)