Al's TAFE Certificate IV I.T. (Website Design) Exercises

Client Side Script 2

Activity One: -

JavaScript Library Code

The code content for jslibrary.js is as follows, in case you do not have access to the network drive. Not all this code is needed for the performing of the inline frame programming, and it would be a good activity for you to work out which coding the iframe page is actually calling on.

 

/* Convert object name string or object reference

into a valid object reference */

function getObj(elementID){

if (typeof elementID == "string") {

return document.getElementById(elementID);

}else{

return elementID;

}

}

 

/*Set the background color of an object*/

function setBackground(thisobj, color){

getObj(thisobj).style.background = color;

}

 

/*Set the text color of an object*/

function setColor(thisobj, color){

getObj(thisobj).style.color = color;

}

 

/*Setting the visibility of an object*/

function setVisibility(obj,vis){

var theObj = getObj(obj);

if (vis == true || vis=='visible' || vis=='y'){

theObj.style.visibility = "visible";

}else{

theObj.style.visibility = "hidden";

}

}

/*Getting the visibility of an object*/

function isVisible(obj) {

var theObj = getObj(obj);

return theObj.style.visibility;

}

 

/*Setting the display of an object*/

function setDisplay(obj,dis){

var theObj = getObj(obj);

if (dis==true || dis=='block' || dis=='y'){

theObj.style.display = "block";

}else{

if (dis==false || dis=='n'){

theObj.style.display = "none";

}else{

theObj.style.display = dis;

}

}

}

/*Getting the display of an object*/

function isDisplayed(obj) {

var theObj = getObj(obj);

return theObj.style.display;

}