mlitty
04-20-2007, 03:07 PM
Hi.
I'm new to Dom Scripting and using Jeremy Keith's Dom Scripting book as a guide.
My code is giving me a code error in IE but working smoothly in FF, and passes the JSLint.com validator.
Below is the relevent snipet of code. It's at the very top of my script. The line that triggers the error is ...
if (templateClass.indexOf("bottom") != -1 ) {
I don't have IE at home (linux user), but I believe the error was ...
templateClass is null or Not an object
and happens at the top of the templateTweak function. It's right out of the DOM Scripting book, works in FF and errors in IE.
Thanks for helping...
var bodyTag = document.getElementsByTagName("body");
var templateId ;
var templateClass;
var displayArea; /* This is where we'll append Image and Caption code */
var description; /* This is where we'll append a caption for the display */
var descText;
window.onload = function() {
templateTweak(); /* Make adjustments based on the teplate */
makeDisplay();
/*idLinks(); uses GetElementById to find links in a particular Id'ed location" */
classLinks(); /* retrieves all of the elements of a certain class */
};
function templateTweak() {
var i=0;
var classSearch = document.getElementsByTagName("div");
templateId = bodyTag[0].getAttribute("id");
templateClass = bodyTag[0].getAttribute("class");
if (templateClass.indexOf("bottom") != -1 ) {
document.getElementById("top").style.visibility = "hidden"; // hide the top bar
for (i; i<classSearch.length; i++) {// search, find, and hide the sideBars
if (classSearch[i].getAttribute("class") == "sideBar") {
classSearch[i].style.visibility = "hidden";
}
}
}
I'm new to Dom Scripting and using Jeremy Keith's Dom Scripting book as a guide.
My code is giving me a code error in IE but working smoothly in FF, and passes the JSLint.com validator.
Below is the relevent snipet of code. It's at the very top of my script. The line that triggers the error is ...
if (templateClass.indexOf("bottom") != -1 ) {
I don't have IE at home (linux user), but I believe the error was ...
templateClass is null or Not an object
and happens at the top of the templateTweak function. It's right out of the DOM Scripting book, works in FF and errors in IE.
Thanks for helping...
var bodyTag = document.getElementsByTagName("body");
var templateId ;
var templateClass;
var displayArea; /* This is where we'll append Image and Caption code */
var description; /* This is where we'll append a caption for the display */
var descText;
window.onload = function() {
templateTweak(); /* Make adjustments based on the teplate */
makeDisplay();
/*idLinks(); uses GetElementById to find links in a particular Id'ed location" */
classLinks(); /* retrieves all of the elements of a certain class */
};
function templateTweak() {
var i=0;
var classSearch = document.getElementsByTagName("div");
templateId = bodyTag[0].getAttribute("id");
templateClass = bodyTag[0].getAttribute("class");
if (templateClass.indexOf("bottom") != -1 ) {
document.getElementById("top").style.visibility = "hidden"; // hide the top bar
for (i; i<classSearch.length; i++) {// search, find, and hide the sideBars
if (classSearch[i].getAttribute("class") == "sideBar") {
classSearch[i].style.visibility = "hidden";
}
}
}