Web server codes are sent by a web server to indicate what is happening. It is useful to understand these codes when configuring a web site.
This is some information I found while researching the 403 error code. Visit, Wikipedia for details.
Allot of times when coding a website, you will come across these codes, and you need to understand them.
Some programming routines will not work unless they are coded a particular way; otherwise, you will get a strange code from the web server.
In this blog I hope to provide information to aspiring web designers, and web developers looking for answers to technical problems. It also serves as an archive of solutions I have found, for myself.
Monday, May 9, 2011
Tuesday, May 3, 2011
Planning for the Future
When writing javascript classes think about what functionality you use most often. Allot of functions can be reused, and will speed development time by packaging them into a class object.
If you are just starting out it may be tough to get your head around javascript classes, but they really aren't that difficult. See my previous blogs about javascript classes.
Form fields are one of the many things that can be packaged and reused. Just check each object to see if it exists on the page, before declaring it, otherwise the browser will object. Functions like one used to get a parameter from an url, or to change the properties of an object on the page can also be packaged.
If you are not using classes, and you are just adding functions to your javascript file as needed, you will eventually run into a rat's nest. The more code you add, the more complicated it gets, and it takes longer and longer to track down a problem.
Some of my projects have javascript files of over 1000 lines of code, and I am now using classes to try and simplify my coding, and make it easier to find things. If you need help, there are lots of places you can go on the Internet to find information about coding javascript classes.
One think to remember is that you must call a method via a function, and you can not just declare a reference to the object you are using.
If you try to declare a public reference to the object, IE will accept it and Mozilla browsers won't. I just use a function called bind with a bunch of case statements to evaluate a parameter, and call the appropriate method.
Packaging up your functions makes allot of sense, especially on projects that use allot of dynamic data. Most websites you design will probably need allot of special functionality to access data, and will add up.
If you put everything into classes, and someone has to go through your code, then they will be able to understand it just as well as you.
If you are just starting out it may be tough to get your head around javascript classes, but they really aren't that difficult. See my previous blogs about javascript classes.
Form fields are one of the many things that can be packaged and reused. Just check each object to see if it exists on the page, before declaring it, otherwise the browser will object. Functions like one used to get a parameter from an url, or to change the properties of an object on the page can also be packaged.
If you are not using classes, and you are just adding functions to your javascript file as needed, you will eventually run into a rat's nest. The more code you add, the more complicated it gets, and it takes longer and longer to track down a problem.
Some of my projects have javascript files of over 1000 lines of code, and I am now using classes to try and simplify my coding, and make it easier to find things. If you need help, there are lots of places you can go on the Internet to find information about coding javascript classes.
One think to remember is that you must call a method via a function, and you can not just declare a reference to the object you are using.
If you try to declare a public reference to the object, IE will accept it and Mozilla browsers won't. I just use a function called bind with a bunch of case statements to evaluate a parameter, and call the appropriate method.
Packaging up your functions makes allot of sense, especially on projects that use allot of dynamic data. Most websites you design will probably need allot of special functionality to access data, and will add up.
If you put everything into classes, and someone has to go through your code, then they will be able to understand it just as well as you.
Saturday, April 23, 2011
Javascript Class's
Create realistic 3d images, broadcast ready, using industry-leading 3d Modelling/Animation and Game Design software used by animation studios with Illusion Image.

Order It Here!
JavaScript classes are helpful when building online forms, displaying dynamic content using Ajax, and to keep your functions centralized.
When working on a website with allot of dynamic content, it can become an overwhelming task to comb through hundreds of lines of code, to track down one function. Until learning how to incorporate class's into my work, I would waste allot of time combing through over a thousand lines of code to find a problem.
JavaScript classes not only keep your functions centralized, they lend themselves to re-usability, which is how they came about. Lets say for example, you build allot of forms with the same fields. You can code one file with a bunch of generic fields, and call them into all your online web forms. Just remember to check to see if the object exits.
For example;
this.Element = document.getElementById("name_of_field");
if (this.Element != null) // Check object exists
{
This way the generic field does not necessarily need to be part of the page you are working on.
Lets get down to the nuts and bolts of the class. I won't get into much detail here only the basics.
Use the new keyword to define an object belonging to a class.
For example;
var myobject = new customer();
To refer to the properties and methods belonging to your object.
myobject.customer_name;
Define your class like this. Always use the this keyword to define your properties in the class. Properties are like variables in a function. This class was taken from the current project I am working on, but will give you an idea of how to construct your class.
function operation_routines(){
//Update row property
operation_routines.prototype.updatedisplay = function (rec){
this.rec = parseInt(rec); //Get record
this.Element = document.getElementById("recordnumber");
if (this.Element != null) // Check object exists
{
if (document.getElementById("recordnumber").value!="")
{
//Recordnumber must be greater than zero to uncheck the previous record. If the record is
//zero, the old record does not exist.
if (document.getElementById("recordnumber").value>0){
//selectedrow=eval(document.getElementById("recordnumber").value) + 100;
this.selectedrow=parseInt(document.getElementById("recordnumber").value) + parseInt(100);
//chk=document.getElementById(selectedrow.toString());
//alert("test" + this.selectedrow);
this.chk=document.getElementById(this.selectedrow);
this.chk.checked=false;
this.rw_num=document.getElementById("recordnumber").value;
//Set old row color to blank.
this.temp = document.getElementById(this.rw_num);
this.temp.style.backgroundColor=""; //Set old
}
}
//document.getElementById("recordnumber").value=record_numb; //Save new record number
document.getElementById("recordnumber").value=this.rec; //Save new record number
//Set current row color.
this.rw_clr = document.getElementById(document.getElementById("recordnumber").value);
this.rw_clr.style.backgroundColor="yellow";
} //End of first if statement.
}
//Display editor
operation_routines.prototype.text_editor = function (){
this.Element = document.getElementById("txt_addr");
if (this.Element != null) // Check object exists
{
//this.temp = document.getElementById("txt_sum").value;
// Use it to attach the editor to all textareas with full featured setup
//WYSIWYG.attach('all', full);
// Use it to attach the editor directly to a defined textarea
WYSIWYG.attach('txt_addr', full); // full setup
// Use it to attach the editor directly to a defined textarea
WYSIWYG.attach('txt_sum', full); // full setup
//document.getElementById("txt_sum").value = this.temp;
// Use it to attach the editor directly to a defined textarea
WYSIWYG.attach('txt_desc', full); // full setup
// Use it to attach the editor directly to a defined textarea
//WYSIWYG.attach('txt_desc', small); // small setup
}
} //End of text_editor
//Strip
operation_routines.prototype.strip_para = function (){
this.Element = document.getElementById("txt_sum");
if (this.Element != null) // Check object exists
{
this.str_cng1=window.frames[0].document.body.innerHTML;
this.chng1 = this.str_cng1.replace(/
window.frames[0].document.body.innerHTML=this.chng2;
}
} //End of strip_para
operation_routines.prototype.get_newrentalapps = function (){
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="../admin/inc/list_docs.php";
var blank = "";
url = url+"?parm=" + blank;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
} //End of get_newrentalapps
} //End of class
Unfortunately, due to the way Mozilla and Internet Explorer work, you can't just declare a pointer to access an object in your JavaScript file. Mozilla will work fine, but IE, like for allot of other things won't. To get around that problem, I created a function called bind. It uses a parameter to determine which method to access.
Example;
bind(name_of_function){
Use case switch to call the correct method for the functionality you are trying to enable on your page.
}
When building your classes, be careful, think about re-usability and centralization. If your just starting out as a professional web developer, you will thank me for writing this blog if you take the time to write classes for the functions in your projects.
There are many resources on the internet to draw on for assistance like, http://javascript.about.com/library/bltut35.htm, or check out, http://www.w3schools.com.
Create realistic 3d images, broadcast ready, using industry-leading 3d Modelling/Animation and Game Design software used by animation studios with Illusion Image.

Order It Here!
Order It Here!
JavaScript classes are helpful when building online forms, displaying dynamic content using Ajax, and to keep your functions centralized.
When working on a website with allot of dynamic content, it can become an overwhelming task to comb through hundreds of lines of code, to track down one function. Until learning how to incorporate class's into my work, I would waste allot of time combing through over a thousand lines of code to find a problem.
JavaScript classes not only keep your functions centralized, they lend themselves to re-usability, which is how they came about. Lets say for example, you build allot of forms with the same fields. You can code one file with a bunch of generic fields, and call them into all your online web forms. Just remember to check to see if the object exits.
For example;
this.Element = document.getElementById("name_of_field");
if (this.Element != null) // Check object exists
{
This way the generic field does not necessarily need to be part of the page you are working on.
Lets get down to the nuts and bolts of the class. I won't get into much detail here only the basics.
Use the new keyword to define an object belonging to a class.
For example;
var myobject = new customer();
To refer to the properties and methods belonging to your object.
myobject.customer_name;
Define your class like this. Always use the this keyword to define your properties in the class. Properties are like variables in a function. This class was taken from the current project I am working on, but will give you an idea of how to construct your class.
function operation_routines(){
//Update row property
operation_routines.prototype.updatedisplay = function (rec){
this.rec = parseInt(rec); //Get record
this.Element = document.getElementById("recordnumber");
if (this.Element != null) // Check object exists
{
if (document.getElementById("recordnumber").value!="")
{
//Recordnumber must be greater than zero to uncheck the previous record. If the record is
//zero, the old record does not exist.
if (document.getElementById("recordnumber").value>0){
//selectedrow=eval(document.getElementById("recordnumber").value) + 100;
this.selectedrow=parseInt(document.getElementById("recordnumber").value) + parseInt(100);
//chk=document.getElementById(selectedrow.toString());
//alert("test" + this.selectedrow);
this.chk=document.getElementById(this.selectedrow);
this.chk.checked=false;
this.rw_num=document.getElementById("recordnumber").value;
//Set old row color to blank.
this.temp = document.getElementById(this.rw_num);
this.temp.style.backgroundColor=""; //Set old
}
}
//document.getElementById("recordnumber").value=record_numb; //Save new record number
document.getElementById("recordnumber").value=this.rec; //Save new record number
//Set current row color.
this.rw_clr = document.getElementById(document.getElementById("recordnumber").value);
this.rw_clr.style.backgroundColor="yellow";
} //End of first if statement.
}
//Display editor
operation_routines.prototype.text_editor = function (){
this.Element = document.getElementById("txt_addr");
if (this.Element != null) // Check object exists
{
//this.temp = document.getElementById("txt_sum").value;
// Use it to attach the editor to all textareas with full featured setup
//WYSIWYG.attach('all', full);
// Use it to attach the editor directly to a defined textarea
WYSIWYG.attach('txt_addr', full); // full setup
// Use it to attach the editor directly to a defined textarea
WYSIWYG.attach('txt_sum', full); // full setup
//document.getElementById("txt_sum").value = this.temp;
// Use it to attach the editor directly to a defined textarea
WYSIWYG.attach('txt_desc', full); // full setup
// Use it to attach the editor directly to a defined textarea
//WYSIWYG.attach('txt_desc', small); // small setup
}
} //End of text_editor
//Strip
operation_routines.prototype.strip_para = function (){
this.Element = document.getElementById("txt_sum");
if (this.Element != null) // Check object exists
{
this.str_cng1=window.frames[0].document.body.innerHTML;
this.chng1 = this.str_cng1.replace(/
/ig,'
'); //Change all
to
this.chng2 = this.chng1.replace(/<\/p>/ig,''); //Change all
window.frames[0].document.body.innerHTML=this.chng2;
}
} //End of strip_para
operation_routines.prototype.get_newrentalapps = function (){
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="../admin/inc/list_docs.php";
var blank = "";
url = url+"?parm=" + blank;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
} //End of get_newrentalapps
} //End of class
Unfortunately, due to the way Mozilla and Internet Explorer work, you can't just declare a pointer to access an object in your JavaScript file. Mozilla will work fine, but IE, like for allot of other things won't. To get around that problem, I created a function called bind. It uses a parameter to determine which method to access.
Example;
bind(name_of_function){
Use case switch to call the correct method for the functionality you are trying to enable on your page.
}
When building your classes, be careful, think about re-usability and centralization. If your just starting out as a professional web developer, you will thank me for writing this blog if you take the time to write classes for the functions in your projects.
There are many resources on the internet to draw on for assistance like, http://javascript.about.com/library/bltut35.htm, or check out, http://www.w3schools.com.
Create realistic 3d images, broadcast ready, using industry-leading 3d Modelling/Animation and Game Design software used by animation studios with Illusion Image.
Order It Here!
Subscribe to:
Posts (Atom)