M
mk834tt
This is an example in "DOM Scripting". It works. I don't understand
why.
window.onload = function() {
if (!document.getElementsByTagName) return false;
var lnks = document.getElementsByTagName("a");
for (var i=0; i<lnks.length; i++) {
if (lnks.getAttribute("class") == "popup") {
alert("is pop up type class");
lnks.onclick = function x() {
popUp(this.getAttribute("href"));
return false;
} } } }
And here is the anchor
<a href="http://www.dogpile.com" class="popup" >POPUP</a><br/>
To create his "unobtrusive" javascript, there is a test for existence
of getElementByTagName. He returns false if it does not exist. I
thought false precluded the default behavior or the <a> element.
Shouldn't the test return true if the object is not found so that the
page can load dogpile?
Thanks
why.
window.onload = function() {
if (!document.getElementsByTagName) return false;
var lnks = document.getElementsByTagName("a");
for (var i=0; i<lnks.length; i++) {
if (lnks.getAttribute("class") == "popup") {
alert("is pop up type class");
lnks.onclick = function x() {
popUp(this.getAttribute("href"));
return false;
} } } }
And here is the anchor
<a href="http://www.dogpile.com" class="popup" >POPUP</a><br/>
To create his "unobtrusive" javascript, there is a test for existence
of getElementByTagName. He returns false if it does not exist. I
thought false precluded the default behavior or the <a> element.
Shouldn't the test return true if the object is not found so that the
page can load dogpile?
Thanks