R
E
S
O
U
R
C
E
S
       Question Index      Products & Services      Contact Us      Links


WebHatchers will design & develop your site for you.
_______________________

Website Menu Heaven: side or top popup menus, buttons, image rotators, navbars, tons more.
_______________________

Send us your questions and wittiest comments.
_______________________

Report errors on our site.
_______________________

Share your neatest DHTML examples with us; we may publish them.
_______________________


_______________________

      QUESTION INDEX      

Question Index
Browser Insanity
JavaScript
Animation
Buttons and Menus
CSS and HTML
PHP
Personal Status Boards
Content Management
   Systems
Website Directory
   CMS Systems


 INFORMATIVE ARTICLES 

Menus-and-Buttons-
Part-I.htm


Menus-and-Buttons-
Part-II.htm


Change-Div-Size-Color-
and-Location-with-the-
W3C-DOM.htm


Bouncing-Ball-Animation-
with-the-W3C-DOM.htm


Style-Changes-with-the-
W3C-DOM.htm


Animation-with-the-
W3C-DOM.htm


Window-Play-and-Some-
Important-DOM-Methods.htm


Using-getElementsByTagName
-and-getElementsByName.htm


The-CSS-Resources-Intro-
Page.htm


Convert-Word-Files-to-HTML-
and-Install-Editor2-to-
Use-Instead-of-NotePad.htm


CSS-Issues.htm

What Are Fifteen Simple Methods of Doing Web-Page Pop-ups?

Security levels from Javascript and PHP input filtering

What is a regular expression general input validator?

What is a regular expression user name validator?

What is a regular expression password validator?

What is a regular expression email validator?

What is a regular expression URL validator?

How can I convert a Javascript array to a PHP array?

How can I Dynamically Create Input Boxes with Validation?

How do I use JavaScript Object Notation (JSON) in PHP and JavaScript to convert strings and arrays from PHP to JavaScript?

How do I add html to a web page with JavaScript, PHP or ssi includes?

How do I add html to a web page with JavaScript includes?


PHP

How do you put PHP variables in URL and link text?

What is PHP Code for Multiple PSB Hosts?

What is Registration PHP Code for Multiple PSB Hosts?

What is Registration PHP Code for Multiple PSB Hosts with a captcha?

What is Administrator PHP Code for Multiple PSB Hosts?

What's the PHP code for a script for a PSB?

What's the PHP code for a script for PSB updating?

What's the PHP code for a script if you forgot your user name?

What's the PHP code for a script if you forgot your password?

What's the PHP code for a script to change a member's email address?

What's the PHP code for a script to connect to a MySQL database?

What's the PHP code for a script to close a member's account?

What's the PHP code for a script to edit group member?

What's the PHP code for a script to add group member?

What's the PHP code for a script to reset a MySQL table's data to its original?

What's the PHP code for a script to edit a MySQL table's data?

What's the PHP code for a script to change a username?

What's the PHP code for a script to change a password?

What's the PHP code for a script to delete group member?

What's the PHP code for a script to view membership data?

What's the PHP code for a script to change an administrator's password?

What's the PHP code for a script to logout?

What's the PHP code for a script to login?

Security levels from Javascript and PHP input filtering

Security levels and PHP

How can I convert a Javascript array to a PHP array?

What is PHP Code to Prevent Duplicate Data Input - Like User Names or Members?

What is PHP Code for PSB Status Update for Multiple PSB Hosts?

How do I sort 1 PHP array and have the other arrays sort in parallel to how the first array sorts?

How do I use JavaScript Object Notation (JSON) in PHP and JavaScript to convert strings and arrays from PHP to JavaScript?

How do you do PHP-to-JavaScript String Conversion with No JSON?

How do you Convert PHP String to JavaScript String?

How do you Post a JavaScript Array to a PHP Array?

How do you send a value to PHP using JavaScript?

Info on unwanted primary field auto-sorting

How can I do instant article font size, font family, and paragraph formatting with radio buttons?

How can I create custom HTML tags that are safer for MySQL databases?

How can I edit text from MySQL databases by using a textarea box?

How can I highlight matched search terms in a MySQL database table search?

How can I search using not only exact phrase matching but also a series of words to match in a MySQL database table search?

What's the code for an Ajax and PHP Based Input Filter?

Ajax and PHP Based Insult Auto-Completer

How can I use PHP and MySQL for Checking Key Codes to Allow Update to a New Software App Version?




Personal Status Boards (PSB™)

Standard Free PSB

PSB Pro Version

Social PSB

Social PSB Plus (with Email)

Business PSB

Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement




Article Content Management System

Content Management System Introduction

Content Management System—Article Navigation

Content Management System—Article Indexing

Content Management System—Article Editing

Content Management System—Article Searching

Content Management System—Article Deleting

Content Management System—Article Writing

Content Management System—Article Reading

What are the terms of use for our Article Content Management System?




Website Directory Content Management System

Website Directory—Delete Category

Website Directory—Delete URL

Website Directory—Add URL

Website Directory—Add Category

Website Directory—Directory Creating

Website Directory—View by Category (Demo Code)

Website Directory—View by URL (Demo Code)

Website Directory—View by Category (Demo)

Website Directory—View by URL (Demo)

Website Directory—View

Website Directory—View (Demo)



Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

InnerHTML and Directory Creation: Browser Nightmares

In reference to the creation of a web site with a directory that is based on JavaScript arrays stored in external .js files, let’s just say that if the browsers were all perfectly programmed, W3C compliant, bug-free, or at least if they listed all their serious bugs and gave workarounds, the task would be merely a neat challenge. But in actual fact, directory creation ran into piles of browser bugs and quirks and limitations and the very unwelcome Mac "pop-up safety" filters that crippled rerendering of records with JavaScript. Safari, in particular, when faced with record rendering JavaScript, and with search and sort routines, would just simply bomb—and this was scripting that IE5.5 and IE6.0 and Firefox and Mozilla and Netscape easily handled. And Opera didn’t bother to bomb when it encountered this scripting—it was too busy being insane. On an XP with Opera it displayed okay but events didn’t work, but the same code on Windows 98 on Opera made all the web display content line up vertically like soldiers waiting in a chow line! A Browser with under 1% of the market deserves supporting only if it is consistent and not a bugatorium, or at very least very similar to an existing popular browser like IE or Firefox. We ended up using an alert to urge Opera users to use IE or Firefox on the directory.

The following browsers required lots of hard work and experimentation to create workarounds for their bugs and quirks, but once this work was done, all three main functions of the directory (displaying record data and pictures, sorting, searching) were fully operational.

IE5.5
IE6.0
Firefox—recent 2006
Mozilla—recent 2006
Netscape—recent 2006

The following browsers were hopeless re: searching and sorting but we were able to get data and picture display to work fine. With the Mac Safari browser, once we got it fully functional it would crash after searches and sorts so we commented out these functions and let it do display only. With IE5 on the Mac, we not only couldn’t get it to search and sort due to its rerendering craziness, we were also unable to make record details pop up (as a result of the cursor hovering over the record) in a DIV superimposed upon the record being viewed. So in the OS 9 and OS X IE5 browser, we had to settle for clicking on the record and getting a new window, complete with scroll bar, which requires closing by hand—nothing automatic here.

Mac IE5 OS 9 on a G3
Mac IE5 OS X on a G3
Mac Safari—most recent one that works in a G3

Bug Swatting and Other Fun Activities

It’s sad, but here's a summary of how browsers responded to our directory JavaScript. Once challenged with code that would allow them to show their wondrous JavaScript handling capabilities, they either rolled over and played dead like lazy hound dogs or tried to do their job and fell on their faces. We've no idea how browsers other than those mentioned might respond to our code, nor do we care that much, but for a browser like Opera to have so much trouble and inconsistencies with scripts, and for it to blow up so flamboyantly, merely made us decide it would no longer be included in any web site testing regimens. The workarounds that the other 8 browsers needed were weird and not encouraging—but they were doable, if one was patient enough.

InnerHTML?—Oh, Ya Know, It’s Not Really W3C Compliant

Okay, guys, the jig is up! This is no excuse for supporting it so poorly! Most browsers will let coders use innerHTML for a few simple little operations like changing text in a paragraph, but woe be unto him who tries to really use the innerHTML property seriously!

In doing a directory that uses JavaScript arrays, properties, events, and methods to display records (and redisplay them after searches and sorts), the innerHTML property is essential. NodeValue and CreateTextNode properties are fine for text adding and changing but when HTML codes (lots of them) need to be in the mix, the idea of using W3C compliant straight DOM methods becomes formidable and—as anyone can find out with a few benchmark tests—very slow as well. JavaScript expert Peter-Paul Koch, in his Quirksmode site, says: "The most obvious conclusion of these tests is that innerHTML is faster than ‘real’ W3C DOM methods in all browsers. The W3C DOM table methods are slow to very slow, especially in Explorer."

Microsoft did a great thing inventing innerHTML, as it is one of the most useful and well supported (due to its great usefulness and ease of use) of all JavaScript properties. With so many sites using it, it’s browser suicide to fail to support it. So they all do. THAT’S the GOOD news. Now for the BAD news.

THEY SUPPORT IT LIKE CRAP!

The even worse news is that even IE supports it poorly! So why the rotten support and why all the bugs in the type of support browsers give to this wonderfully useful little innerHTML command? Excuses:

  1. It was just a Microsoft afterthought—let’s just patronize ol’ Bill and give it token support to be good sports.
  2. It’s not real DOM.
  3. It’s not W3C compliant.
  4. It inserts HTML code as strings rather than truly inserted nodes that work right.
  5. It’s weird.
  6. No one said "Simon says."

Since all these excuses except the last two seem to have a tad of validity, let’s look at them, with the exception of 5 and 6, which you have permission to ignore: Excuses 2 and 3 turn out to be copouts since the DOM needed this property very much for completeness, ease of use, more capability, speed of execution, and just common sense. We’re all quick enough to put down Bill’s Boys when they goof up—how about we give them credit when they do something very smart!? In actual fact, no matter what anyone tells you, innerHTML was a serious JavaScript need nearly from the start, and the fact that it was omitted from W3C DOM specs was an error that Bill’s Boys rightly cured and most JavaScript coders are very grateful about that! The W3C and DOM think tanks should have immediately embraced it and incorporated it into official W3C DOM immediately rather than turning up their noses and acting like it was a fifth leg on a dog. In incorporating it, they should have described how to implement it so it takes the new code and adds it to official page node content so the code can actually function reliably and predictably.

Oh, on simple pages "innerHTML Lite" works—where you replace a sentence and don’t have real node ramifications. But "innerHTML Serious"—that’s another matter!

Let’s look at the facts: we want our DOM to be about DYNAMIC web page changes, creation, manipulation, and creativity. Normal, official DOM is great stuff and does all this nicely, but innerHTML is even more the essence of what the DOM/DHTML is about than official DOM/DHTML! All that were needed were clean implementation specs and the web world scripters would have been happier than pigs in poop! But what happened? Apparently, the W3C were embarrassed they didn’t think of it first. So they kept it as an "outsider" and as a result the browser coders implemented it sketchily, stupidly, with little insight or foresight, and, above all, buggily!

This apparently disconcerted or distracted Bill’s Boys so much that rather than finishing their implementation so the innerHTML properties became incorporated as deeply as other nodes being tracked by the browser, they kept their implementation superficial, thereby losing a great opportunity to be a great example to other browser coders re: the immense potentials of their wonderful innerHTML invention! Shame on them, and shame on ALL the browser makers and the W3C for a classic missed opportunity. What our experience has shown us is that the innerHTML implementation among browsers and platforms is chaotic, inconsistent, and misunderstood. The purists curse innerHTML’s birth but hypocritically bewail the slowness and huge amount of code needed to do what innerHTML does swiftly and with a line or two of code.

There needs to be a book written that describes exactly how to implement innerHTML in a cross-browser and cross-platform context that includes IE5.5 and IE6 and IE7, Firefox, Mozilla, Netscape, and Mac IE5 (OS 9 and OS X) and Mac Safari. (These are the only ones we test on, and if we say "worked on all browsers and platforms," below, we’re referring to these only. We haven't had a chance to add IE7 to our testing browsers yet as of September 2006—but we soon will. The book should address this browser too. Our experience casts doubt on the value of worrying about Opera—but if anyone can figure out a consistent innerHTML strategy for it, that should be in the book too.) As it is, implementations are so buggy and inconsistent that coders have to experiment and hope to get lucky, when for the rest of their JavaScript they depend on skill, logic, experience, and insight.

Methodology

Important CSS style, link and image name details had to be in the strings that got put into each record’s innerHTML property. Normal DOM methods and properties were user where reasonable. Below we are fixing a bug of a missing div bottom border that IE had, but Firefox, Netscape and Mozilla did not.

ee.parentNode.removeChild(ee)

f=document.createElement("div")

f.innerHTML="<DIV id='w' STYLE='z-index:2;background-color:transparent;position:absolute;padding:10px;border:1px solid black;border-bottom:"+dd+";top:344px;height:"+b+";left:

27px;width:778px;'></DIV>"

document.body.appendChild(f)

f.setAttribute("id","w")

Printing was done from a window, and surprisingly, all browsers and platforms liked this code:

wi = window.open('', 'p')

wi.document.open()

element=document.getElementById("o")

wi.document.write(element.innerHTML)

wi.print()

wi.document.close()

wi.close()

Appending child nodes was done as normally as possible—this worked on all browsers and platforms:

function childmaker(){

node=document.createElement("div")

node.innerHTML=zz

document.getElementById("k").appendChild(node)

node.setAttribute("id",cc)}

And removing the divs before a sort was likewise normal DOM:

e.parentNode.removeChild(e)

One div height display bug was so serious in IE that it needed for the screen to scroll up and down for a microsecond in order to deal with it:

window.scroll(0,9999); window.scroll(0,0)

In order to squash the notorious IE z-index bug during record display, we had to add an extra div (w) to hold all the records, and each time records are recreated, we recreated a sibling (w) to main parent div k at z-index level –1 and made it transparent and then put background-colored div boxes on all 4 sides of the central block of displayed records (data and images)—talk about Mickey Mouse! Once again, normal DOM methods were employed where possible; all the next code block was for IE only due to its div z-index and innerHTML bugs—other browsers didn’t need any of this:

box=document.getElementById('w')

box.parentNode.removeChild(box)

node=document.createElement("div")

node.innerHTML="<DIV id='w' STYLE='z-index:2;background-color:transparent;position:absolute;padding:10px;border:1px solid black;top:344px; height:" + b + ";left:27px; width:778px;'></DIV>"

document.body.appendChild(node)

node.setAttribute("id","w")

box=document.getElementById('b')

x=x+235

xx=3647+yy-(222 * name_f.length)

x=x.toString() + "px"

xx=xx.toString() + "px"

box.style.top=x

box.style.height=xx

xx=3340+yy

box=document.getElementById('l')

box.style.height=xx

box=document.getElementById('r')

box.style.height=xx

Strings were gotten from arrays in a .js file and concatenated into a long HTML-containing string that was dumped into the innerHTML property (partial code only shown here)—this worked in all browsers and platforms:

g=name_f[p]+" "+name_l[p]

h=email[p]

i=website[p]

ii=my_space[p]


r='<DIV class="record" id="'

rrr='" style="top:'

rr='px";><DIV class="video"><img src="video-'

s='.jpg" border="0"></DIV><DIV class="photo"><img src="photo-'

t='.jpg" border="0"></DIV><DIV STYLE ="text-overflow : ellipsis; overflow : hidden" class="data" id="'

uu='"><BR><B>NAME: </B>'

u='<BR><BR><B>EMAIL: </B><a href="mailto:'

v='">'

w='</a><BR><BR><B>MYSPACE: </B><a HREF="http://'

ww='</a><BR><BR><B>WEB: </B><a HREF="http://'

y='</a>'

oo='<BR><BR><B>' //before aa & gg

aa='For more details, hover over big photos.</B>'

gg=''

z='</DIV></DIV>'


zz=r + cc + rrr + b + rr + d + s + d + t + bb + uu + g + u + h + v + h + w + ii + v + ii + ww + i + v + i + y + oo + aa + gg + z


node=document.createElement("div")

node.innerHTML=zz

When the cursor hovers on a record, the full details of the record are shown on a div that pops up on top of the record. This involved taking a div that was hidden at left:-800px and moving it 822 pixels rightwards to left:22px. Mac IE5 was having none of it—it screamed until we were forced to use window pop-ups and replace pop-ups activated with hovering with mouse-click activation.

ee=document.getElementById('o');ee.style.left='22px';

ee.innerHTML=dt

The onKeyPress event is something that was needed to give visitors a convenient way to keep a pop-up popped while they scrolled the scrollbar examining record details on the pop-up. But the Mac only lets coders use this if the visitor is doing "legitimate" keyboard-based input like text or select. The Apple Developers site confirms this. The Firefox/Mozilla/Netscape trio sang an even lamer song: it wouldn’t pick up key hits until a mouse click had occurred first. We cured this, but, are embarrassed to admit—we have no idea how. It just suddenly started behaving on all these browsers, and we’d been working on fine-tuning styles with DOM, not events at all. If anyone can shed any light on this strange Gecko behavior or any workarounds for Apple deafness to key hits unconnected to keyboard input, we’d be glad to hear about it!

Summary

One would think that the amount of createElement, appendChild(), setAttribute, parentNode.removeChild() and removeAttribute() methods (there was lots more than shown) used would have done a more consistent job of fixing the incompleteness of how the innerHTML property does its thing. But browsers were all over the map on their needs in this area and the Mac was abysmal. The way IE5 Mac simply wouldn’t redisplay records (after search or sort) once they’d been put on the page made us see that they were trying to "protect us from pop-ups," as nothing else explains such egregious IE Mac incompetence. Mac’s "protection" seemed to cover all potential pop-up methods, including the use of negative left positions, display: none, visibility: hidden, onLoad used like a true user-controlled event, rerendering anything, and anything with even the slightest taste of innerHTML—apparently equivalent to Satan to Mac browsers. Perhaps it’s just a lia-Bill-ity in their eyes. The Safari browser didn’t even have an "excuse." It just simply crashed after search or sort so on all Windows browsers there are search and sort routines but Mac has neither. More careful innerHTML implementation is likely the key here for Mac browsers.

Which brings us once again to our main thesis: The only GOOD way out of the innerHTML chaos, bugs, and frustration that reflect so poorly on all involved, is inclusion of innerHTML in official W3C DOM—complete with clear implementation specs that include treating the HTML codes dumped into the innerHTML property as legitimate codes, and divs or other objects added or revamped with innerHTML added to the document as legitimate nodes. How many years was the W3C planning to give short shrift to this singularly valuable JavaScript property? Or, put more sagely: sometimes one doesn’t find enlightenment with one’s head in the sand—sometimes one finds only . . . sand.