Archive: Javascript
Learning AJAX: Lesson 3 - XMLHttpRequest
Posted on Thursday, July 12th, 2007
After setting out the groundwork for my AJAX example by creating a random quote generator in PHP then using the DOM to add a link that will perform the AJAX function, I am now ready to start communicating with the server and loading up data without refreshing the page. To do so I need to get to grips with the XMLHttpRequest object.
A Bit Of Background
XMLHttpRequest is not yet a W3C standard, but there is a working draft. It was first implemented by Microsoft in Outlook before making its way to Internet Explorer 5 as an ActiveX Object. Then the Mozilla project got their hands on it, implementing it as a native browser object in Mozilla. The other browsers fell in line soon after. It is now the basis of AJAX and powers most of the web applications available online today.
Continue reading “Learning AJAX: Lesson 3 - XMLHttpRequest” »
Learning AJAX: Lesson 2 - Adding A Link Using The DOM
Posted on Monday, July 9th, 2007
Having made my feelings about not using AJAX before creating a site that can be used fully without it, I have moved on to the next part of my example. Previously, I had a random quote generator that displayed a different quote when you refreshed the page. My aim is to use AJAX techniques to enable you to display a new quote without refreshing the page, but by clicking a link instead. To do so we will need to do some DOM scripting.
The Markup Doesn’t Change
Currently, the example does not have a link to click to replace the quote with a new one. We could add one into the markup so that it could trigger our javascript function that we are still to write, but if a user without javascript enabled visited our page then there would be a useless, broken link. From here on in, the markup for the page will stay the same and everything is to be added dynamically by javascript.
Continue reading “Learning AJAX: Lesson 2 - Adding A Link Using The DOM” »
Learning AJAX: Lesson 1 - Don’t Use AJAX
Posted on Friday, July 6th, 2007
Time to learn some hardcore javascript. Having played with the DOM I have decided that a good use of my time right now to get a start on some AJAX, the buzzword and technology of Web 2.0.
AJAX stands for Asynchronous Javascript and XML, which is a touch misleading as you needn’t use XML. The first part of the name does make sense, however, as the idea is to use javascript to fetch data from the server without reloading a page. It is useful as loading content only is much quicker than a whole page and it makes a web site seem more like standard desktop applications, for more details see the Adaptive Path introduction to AJAX. Continue reading “Learning AJAX: Lesson 1 - Don’t Use AJAX” »
How To Size Your Font Based On Your Reader’s Screen Resolution
Posted on Monday, February 12th, 2007
Through the magic of MyBlogLog statistics, I found someone trying to use one of my javascript codes. It is always touching to find out that someone has found your work useful and it spurs you on to better things.
In this case, the user wanted something slightly different out of the code than what I had provided. Changing a page’s font size was the code in question here, but rather than changing it using the link method I had provided, they wanted to display a different font size based on a reader’s screen resolution. This is an inspired idea, I thought, as monitors get bigger and resolutions get smaller and text on screen disappears. This is why I use 1024×768 otherwise I wouldn’t be able to read anything!
Continue reading “How To Size Your Font Based On Your Reader’s Screen Resolution” »
Stylesheet Switcher - Part 3: Revenge Of IE
Posted on Wednesday, August 30th, 2006
I was just running through my examples yesterday evening, checking they work in IE7 when to my horror my stylesheet switcher failed miserably. I ran to IE6 to see if I had overlooked the problem for IE in general and it turned out that I had. I guess that since the majority of visitors to this site use Firefox (in which the function works perfectly) no-one else had noticed either. The strange thing was that it was only the final version that didn’t work, the first version, using just links rather than the dropdown box, did work. This means that the stylesheet switching function was working fine and there was a problem with the dropdown box.
Continue reading “Stylesheet Switcher - Part 3: Revenge Of IE” »