Lan said:
Thanks for all the great tips Jeremy & pr. I have a few questions.
Jeremy said:
****************************************************
Do you know of any examples I could look at to understand it not
working "as expected"?
Well, that depends on what one expects, of course. But in addition to
the instance (an XHTML document) discussed, you could Google this group
for examples of these:
1. Evaluating innerHTML: browsers produce very different markup
representations of an element, so it isn't safe to expect comparable
results from innerHTML in different browsers.
2. Tables: IE doesn't permit you to replace <table> element content or
rows using innerHTML and you are usually better served - in any browser
- by table object model (eg. insertRow()) or the usual DOM 2.0 methods.
3. Deleting content: you can get unexpected results if you delete
content with innerHTML = "" if a variable refers to one of the nodes
removed and you subsequently try to access that variable. This isn't a
problem using the removeChild() method.
There are no doubt a few more.
strict doctype and get ride of that CDATA stuff then validate your
page.
I agree with that.
[...]
So I have reset the side_bar_html to an empty string towards the end
of the getmarks() function like so:
...
document.getElementById("side_bar").innerHTML = side_bar_html;
}
}
}
request.send(null);
side_bar_html = "";
}
...
Do you think this is an appropriate place to set side_bar_html back to
an empty string? It's working now but I'm just curious if there's a
more beneficial way. Link:
http://dockhawk.com/
I'd put it at the top of that function, just after the variable
declaration, so setting the variable to "" occurs (visually) ahead of
the function calls that set it to a string of markup in the event
listener. That would make the code easier to understand and would
correct the misleading impression given by request.send() appearing the
line before you reset the global variable.