Archive for May, 2009


Useful HTML Meta Tags

Tag Name Example(s) Description
Author <META NAME=”AUTHOR” CONTENT=”Tex Texin”> The author’s name.
cache-control <META HTTP-EQUIV=”CACHE-CONTROL” CONTENT=”NO-CACHE”> HTTP 1.1. Allowed values = PUBLIC | PRIVATE | NO-CACHE | NO-STORE.
Public – may be cached in public shared caches
Private – may only be cached in private cache
no-Cache – may not be cached
no-Store – may be cached but not archivedThe directive CACHE-CONTROL:NO-CACHE indicates cached information should not be used and instead requests should be forwarded to the origin server. This directive has the same semantics as the PRAGMA:NO-CACHE.
Clients SHOULD include both PRAGMA:NO-CACHE and CACHE-CONTROL:NO-CACHE when a no-cache request is sent to a server not known to be HTTP/1.1 compliant.
Also see EXPIRES.
Note: It may be better to specify cache commands in HTTP than in META statements, where they can influence more than the browser, but proxies and other intermediaries that may cache information.
Content-Language <META HTTP-EQUIV=”CONTENT-LANGUAGE”
CONTENT=”en-US,fr”>
Declares the primary natural language(s) of the document. May be used by search engines to categorize by language.
CONTENT-TYPE <META HTTP-EQUIV=”CONTENT-TYPE”
CONTENT=”text/html; charset=UTF-8″>
The HTTP content type may be extended to give the character set. It is recommended to always use this tag and to specify the charset.
Copyright <META NAME=”COPYRIGHT” CONTENT=”&copy; 2004 Tex Texin”> A copyright statement.
DESCRIPTION <META NAME=”DESCRIPTION”
CONTENT=”…summary of web page…”>
The text can be used when printing a summary of the document. The text should not contain any formatting information. Used by some search engines to describe your document. Particularly important if your document has very little text, is a frameset, or has extensive scripts at the top.
EXPIRES <META HTTP-EQUIV=”EXPIRES”
CONTENT=”Mon, 22 Jul 2002 11:12:01 GMT”>
The date and time after which the document should be considered expired. An illegal EXPIRES date, e.g. “0″, is interpreted as “now”. Setting EXPIRES to 0 may thus be used to force a modification check at each visit.
Web robots may delete expired documents from a search engine, or schedule a revisit.HTTP 1.1 (RFC 2068) specifies that all HTTP date/time stamps MUST be generated in Greenwich Mean Time (GMT) and in RFC 1123 format.
RFC 1123 format = wkday “,” SP date SP time SP “GMT”

wkday = (Mon, Tue, Wed, Thu, Fri, Sat, Sun)
date = 2DIGIT SP month SP 4DIGIT ; day month year (e.g., 02 Jun 1982)
time = 2DIGIT “:” 2DIGIT “:” 2DIGIT ; 00:00:00 – 23:59:59
month = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec)

Keywords <META NAME=”KEYWORDS”
CONTENT=”sex, drugs, rock & roll”>
The keywords are used by some search engines to index your document in addition to words from the title and document body. Typically used for synonyms and alternates of title words. Consider adding frequent misspellings. e.g. heirarchy, hierarchy.
PRAGMA NO-CACHE <META HTTP-EQUIV=”PRAGMA” CONTENT=”NO-CACHE”> This directive indicates cached information should not be used and instead requests should be forwarded to the origin server. This directive has the same semantics as the CACHE-CONTROL:NO-CACHE directive and is provided for backwards compatibility with HTTP/1.0.
Clients SHOULD include both PRAGMA:NO-CACHE and CACHE-CONTROL:NO-CACHE when a no-cache request is sent to a server not known to be HTTP/1.1 compliant.
HTTP/1.1 clients SHOULD NOT send the PRAGMA request-header. HTTP/1.1 caches SHOULD treat “PRAGMA:NO-CACHE” as if the client had sent “CACHE-CONTROL:NO-CACHE”.
Also see EXPIRES.
Refresh <META HTTP-EQUIV=”REFRESH”
CONTENT=”15;URL=http://www.I18nGuy.com/index.html”>
Specifies a delay in seconds before the browser automatically reloads the document. Optionally, specifies an alternative URL to load, making this command useful for redirecting browsers to other pages.
ROBOTS <META NAME=”ROBOTS” CONTENT=”ALL”>

<META NAME=”ROBOTS” CONTENT=”INDEX,NOFOLLOW”>

<META NAME=”ROBOTS” CONTENT=”NOINDEX,FOLLOW”>

<META NAME=”ROBOTS” CONTENT=”NONE”>

CONTENT=”ALL | NONE | NOINDEX | INDEX| NOFOLLOW | FOLLOW | NOARCHIVE
default = empty = “ALL”
“NONE” = “NOINDEX, NOFOLLOW”
The CONTENT field is a comma separated list:
INDEX: search engine robots should include this page.
FOLLOW: robots should follow links from this page to other pages.
NOINDEX: links can be explored, although the page is not indexed.
NOFOLLOW: the page can be indexed, but no links are explored.
NONE: robots can ignore the page.
NOARCHIVE: Google uses this to prevent archiving of the page. See http://www.google.com/bot.html
GOOGLEBOT <META NAME=”GOOGLEBOT” CONTENT=”NOARCHIVE”> In addition to the ROBOTS META Command above, Google supports a GOOGLEBOT command. With it, you can tell Google that you do not want the page archived, but allow other search engines to do so. If you specify this command, Google will not save the page and the page will be unavailable via its cache.
See Google’s FAQ.

from http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_r_2.html

As we all know an xmlhttp script requires the use of the readystatechange event. In theory, using the load event is also possible, but Explorer doesn’t support it on xmlhttp requests.

Both these events, and the readyState property, have a few odd quirks when used in an xmlhttp environment, though. These quirks don’t impact standard xmlhttp scripts too much, but as soon as you want to use the event objects or readyStates other than 4 you need to know about them.

readyState

The readystatechange event fires when the readyState of the request changes. This property can have four values, which theoretically work in the way shown below. In practice, though, the browsers don’t quite follow this de facto standard.

0 Uninitialized – open() has not been called yet.
1 Loading – send() has not been called yet.
2 Loaded – send() has been called, headers and status are available.
3 Interactive – Downloading, responseText holds the partial data.
4 Completed – Finished with all operations.

readyState 4 is equivalent to the load event and is a standard part of any xmlhttp script. I have never understood what the other three readyStates are good for; why would you need to know that responseText holds the partial data, for instance? One more mystery to solve.

That said, let’s try the following bit of script. You’d expect four alerts, 1, 2, 3 and 4.

xmlhttp.open("GET","somepage.xml",true);
xmlhttp.onreadystatechange = checkData;
xmlhttp.send(null);

function checkData()
{
	alert(xmlhttp.readyState);
}

Results:

  • Explorer: 1-2-3-4 (correct)
  • Mozilla: 1-2-3-4 (correct)
  • Safari: 2-3-4
  • Opera: 3-4

Where have the missing readyStates gone in Safari and Opera? I have no idea.

Let’s move the event handler assignment to a different point in the code:

xmlhttp.onreadystatechange = checkData;
xmlhttp.open("GET","somepage.xml",true);
xmlhttp.send(null);

Results:

  • Explorer: 1-1-2-3-4
  • Mozilla: 1-1-2-3-4
  • Safari: 1-2-3-4 (correct)
  • Opera: 1-3-4

All browsers now add an extra readyState of 1 at the start of their sequence. Explorer and Mozilla give a “1″ alert twice, and that’s odd, because the event name is clearly readystatechange and a change from 1 to 1 is no change. Opera still lacks the readyState 2. Odd, odd.

Let’s move the event handler assignment again:

xmlhttp.open("GET","somepage.xml",true);
xmlhttp.send(null);
xmlhttp.onreadystatechange = checkData;

Explorer doesn’t react at all if you assign the readystatechange event after the send() method has been called.

  • Explorer: nothing
  • Mozilla: 2-3-4 (correct)
  • Safari: 2-3-4 (correct)
  • Opera: 3-4

In conclusion, no browser correctly supports readyState in all cases. Fortunately the all-important value of 4 is unaffected by this odd series of bugs.

readystatechange

Let’s consider the events themselves:

xmlhttp.open("GET","somepage.xml",true);
xmlhttp.onreadystatechange = checkData;
xmlhttp.send(null);

function checkData(e)
{
	var evt = e || window.event;
	var rs = xmlhttp.readyState || "None";
	alert(evt.type + ' ' + rs);
}

Now you’d expect to get an alert “readystatechange 1″ through 4. Unfortunately only Safari gives this correct response, even though it starts at readyState 2, as we saw above.

  • Explorer: “load 1″, then sometimes error messages, sometimes the “load 2″ through 4 you’d expect. Right now I think the error messages come when the XML document is being really loaded, and the 2 through 4 when Explorer can get the XML document from the cache.
  • Mozilla: error message: event object doesn’t exist
  • Safari: “readystatechange 2″ through 4
  • Opera: error message: event object doesn’t exist

The readystatechange event object is entirely absent in Mozilla and Opera, while Explorer feels its type is a load event.

Another related point:

When you use synchronous loading in Mozilla (ie. browser waits until the XML file has been loaded before doing anything else), the readystatechange event is not available.

This is not a huge problem, because the idea behind synchronous loading is that you wait for the XML file to be available, anyway. The line after the xmlhttp.send(null) is executed only when the XML is there. Nonetheless this point should be noted, too.

load

Explorer has a point in so far as the load event can be seen as a subset of the readystatechange event. load fires when the page has been loaded completely, which is equivalent to saying the readyState is 4: completed.

Let’s try it:

xmlhttp.open("GET","somepage.xml",true);
xmlhttp.onload = checkData;
xmlhttp.send(null);

function checkData(e)
{
	var evt = e || window.event;
	var rs = xmlhttp.readyState || "None";
	alert(evt.type + ' ' + rs);
}
  • Explorer: error message because you assign the unknown property onload to the xmlhttp request
  • Mozilla: “load 4″
  • Safari: “load 4″
  • Opera: error message: event object doesn’t exist

So Explorer doesn’t support the load event on xmlhttprequests. We already knew this, but we should realize it doesn’t even allow you to set the event handler, since it allows only a very limited set of properties on the xmlhttp object.

The event object is still missing in Opera, though not in Mozilla.

Problem:

When doing AJAX call, IE will cache every AJAX call. Hence, url such as ‘/post.do’ will return the same thing and actually the AJAX request will not be sent after the first time.

Solution:

put AJAX url ‘/post.do’ with a time stamp as following:

jQuery.get('/post.do?ts='+(new Date()).getTime());

<?
session_start
();
$_SESSION['mySession'] = "hello";

header ("Location: xpage.php");
exit();
//This sentence do the magic
?>

Powered by WordPress. Theme: Motion by 85ideas.