Bloggeh.com
BJJ, technology, psychology & other cool stuff
BJJ, technology, psychology & other cool stuff
Jun 2nd
Here’s a neat little tool – simply upload your picture and it’ll create the favicon for you!
http://www.chami.com/html-kit/services/Favicon/
Make sure your picture is SQUARE (ie. 32×32)
Place this code on your page once you’ve uploaded the favicon to your server:
<link rel=”Shortcut Icon” href=”favicon.ico”>
Photoshop support has a good little article on favicons which is worth checking out also: http://www.photoshopsupport.com/tutorials/jennifer/favicon.htmlÂ
May 26th
The initial code
We are going to “try” three different ways to make a new XMLHttpRequest object. Every time we fail and get an error, we will catch the error and try the next a different command. This is necessary code for all AJAX applications.
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject(”Msxml2.XMLHTTP”);
} catch (e) {
try{
ajaxRequest = new ActiveXObject(”Microsoft.XMLHTTP”);
} catch (e){
// Something went wrong
alert(”Your browser broke!”);
return false;
}
}
}
Using the XMLHttpRequest object
We have stored our XMLHttpRequest object in the variable ajaxRequest, and using this object is how we will communicate with the server.
The onreadystatechange property
The onreadystatechange property stores the function that will process the response from a server. The following code defines an empty function and sets the onreadystatechange property at the same time:
ajaxRequest.onreadystatechange = function() {
// code goes here.
}
The readystate property
The XMLHttpRequest object has another property called readyState. This is where the status of our server’s response is stored. Each time the readyState changes, the onreadystatechange function will be executed.
| State | Description |
|---|---|
| 0 | The request is not initialized |
| 1 | The request has been set up |
| 2 | The request has been sent |
| 3 | The request is in process |
| 4 | The request is complete |
If the readystate is set to 4, then we can collect/process our data. Going back to the function we created earlier:
ajaxRequest.onreadystatechange = function() {
if (ajaxRequest.readystate == 4) {
// get data from server response
}
}
The responseText property
The data sent back from the server can be retrieved using the responseText property. For example, if you wanted to change the field in a textbox equal to the response from the server you would use:
ajaxRequest.onreadystatechange = function() {
if (ajaxRequest.readystate == 4) {
document.myForm.time.value = ajaxRequest.responseText;
}
}
Sending a request to the server
To send off a request to the server, we use the open() method and the send() method.
The open() method takes three arguments. The first argument defines which method to use when sending the request (GET or POST). The second argument specifies the URL of the server-side script. The third argument specifies that the request should be handled asynchronously. The send() method sends the request off to the server.
If your PHP/ASP script was in the same directory as this Ajax script, your code would look like this:
ajaxRequest.open(”GET”, “time.php”,true);
ajaxRequest.send(null);
Activating AJAX in a form
Let’s say that you wanted the AJAX request to be fired off each time a field was completed in a form. You could use the code below:
<form name=”myForm”>
Name:<input type=”text” onChange=”ajaxFunction();” name=”username” />
Time: <input type=”text” name=”time” />
</form>
Credit goes to: http://www.tizag.com and http://www.w3schools.com
May 23rd
Cool script which displays ‘help text’ in a text box until it’s selected, then it disappears and allows the user to input text. It’s simple and just a few lines of javascript!
Javascript:
function clearText(field){
if (field.defaultValue == field.value) field.value = ”;
else if (field.value == ”) field.value = field.defaultValue;
}
Textbox input:
<input name=“s” type=“text” maxlength=“106″ id=“icePage_SearchBoxTop_qkw” class=“wsSearchBoxInputCommon wsSearchBoxInput” value=“Enter suburb name here, eg: hawthorn” onFocus=“clearText(this)” onBlur=“clearText(this)”/>
Apr 8th
Generate the cool ‘Web 2.0′ loading images for your webpage using this vast collection!
Feb 5th
The link below discusses what form format works the best using eye trackers and speed of completion. Labels directly above the textboxes were the best in their eyes.
http://www.uxmatters.com/MT/archives/000107.php
Sitepoint also has a great article on creating a useable form.
http://www.sitepoint.com/article/fancy-form-design-css/2
Jan 10th
A good lightbox alternative, extremely lightweight (22kb!)
http://www.orangoo.com/labs/GreyBox/
There are issues with flash overlapping the greybox in Firefox 2+.? After hours of playing around I came up with the solution below:
1. Add wmode=”opaque” to the embed tag
2. Add the paramater: param name=”wmode” value=”opaque”
3. Put the flash content in a div, and set the z-index of that div to 2.
4. Place the content you are wanting to display in the greybox also in a div, with a z-index of 1.
Presto!
Nov 16th
In compressed form has a very light footprint of only 10kb.? ? The validation isn’t laggy at all. Excellent tool.