Tutorial Open Link in a New Window

by in , 0

HTML attribute (valid in HTML5 now):

<a href="http://chriscoyier.net" target="_blank">This link will open in new window/tab</a>

Inline JavaScript way:

<a href="http://chriscoyier.net"  onkeypress="window.open(this.href); return false;">This link will open in new window/tab</a>

With jQuery:

See here

Tutorial Multiple File Input

by in , 0

File inputs can have an attribute of "multiple" which then allows multiple files to be selected in the file section dialog box. Firefox 3.6+ and WebKit browsers only are supporting it so far. Unfortunately the "multiple files" need to be within the same folder, as there is no interface for selecting one, moving folders, and selecting another.

<form method="post" action="upload.php" enctype="multipart/form-data">
  <input name='uploads[]' type="file" multiple>
  <input type="submit" value="Send">
</form>

Note that the "name" of the file input has brackets at the end of it. This isn't required per the spec but is required to process the multiple files.

In PHP, you can then loop through the data as an array:

foreach ($_FILES['uploads']['name'] as $filename) {
    echo '<li>' . $filename . '</li>';
}

Reference URL

Tutorial Meta Tag to Prevent Search Engine Bots

by in , 0

To prevent all search bots from indexing a page:

<meta name="robots" content="noindex">

To prevent just Google:

<meta name="googlebot" content="noindex">

If you have control over it, you probably want to add nofollow to links that point to that page as well:

<a href="privatepage.html" rel="nofollow">Link to private page</a>

Theoretically that's not needed for Google, which claims to drop all pages with noindex from their directory. But there are more search engines out there and it doesn't hurt.

Reference URL

Tutorial Meta Tag For Forcing IE 8 to Behave Like IE 7

by in , 0

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

Source: Microsoft

Some reports that IE 8 in IE 7 mode doesn't quite behave like either one.

Tutorial Meta Refresh

by in , 0

The redirects to the provided URL in 5 seconds. Set to 0 for an immediate redirect.

<meta http-equiv="refresh" content="5;url=http://example.com/" />

Tutorial Make IE 6 Crash

by in , 0

This is absolutely NOT recommended for use in any sort of "real" website scenario. It's just kind of funny and interesting.

<style>*{position:relative}</style><table><input></table>

Tutorial Mailto Links

by in , 0

Basic

Open default mail program, create new message with the TO field already filled out.

<a href="mailto:someone@yoursite.com">Email Us</a>  

Adding a subject

Open default mail program, create new message with the TO and SUBJECT field already filled out. Essentially we are adding the parameter subject to the href value.

Spaces in the subject will probably work OK, but to be super-extra sure, you can replace spaces with "%20".

<a href="mailto:someone@yoursite.com?subject=Mail from Our Site">Email Us</a>  

Adding CC and BCC

Open default mail program, create new message with the TO, SUBJECT, CC, and BCC field already filled out. Essentially we are adding the parameters cc and bcc to the href value.

Also note that you add multiple values to CC and BCC by comma separating them.

<a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News">Email Us</a>

Adding Body Text

Just add the body parameter into the ever-growing list of parameters we are using.

<a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News&body=Body-goes-here">Email Us</a>