August 30th, 2006

How to make a link open in a new window with XHTML

The old-fashioned method of opening a link in a new window is to use the attribute target="_blank". Unfortunately, if you use an XHTML validator, you'll find that this attribute has been deprecated. Originally it was proposed to use the 'rel' attribute, like this: rel="external". Although this validates, it doesn't cause the browser to open a new window.

So, here's a way using JavaScript to have valid XHTML, and have your links open in a new window! Just make sure your links have the rel="external" attribute set, then add this JavaScript code to the <head> section of your web page. It will loop through your links, and dynamically add the old target="_blank" to the element, but this is on the client-side, so no errors in validation are caused.

addLoadEvent(externalLinks);

function externalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") &&
      anchor.getAttribute("rel") == "external")
      anchor.target = "_blank";
    }
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

If you're going to use this method throughout your site, it would make sense to place this code in an external .js file, and reference it in the <head> if you page, like this:

<script src="external_links.js" type="text/javascript"></script>
August 14th, 2006

How to Build a Simple Chat Application with PHP

Do you have an online support system with which you'd like to be able to enable live chat? Well, you can either pay for a service hosted by a 3rd party, or you could easily just build one yourself unsing PHP. This simple chat system will take user input from an HTML form, store it in a text file, and display it on the screen. (more…)

August 2nd, 2006

PHP: Insert Into an Array at a Specific Position

It's fairly simple to add an element to an array in PHP, but doing just appends the value/element to the last position in the array. You could hack the array_splice function to attempt the, and the format would be like this: array_splice($array, $pos, 0, $newelement); (you could even insert an entire array into the array!). But this function has been created for the sole purpose of inserting into an array, and it's called array_insert(). (more…)

August 2nd, 2006

The Russian Futurists - Paul Simon

This is probably the coolest new song I've heard in months! I just had to post this, so here's the link to stream or download the MP3 of The Russian Futurists - Paul Simon

August 1st, 2006

Build Your Email Subscriber List with Joomla/Mambo and GetResponse

Web

Create beautiful Joomla websites with a flexible layout from iJoomla.com

This is a free Joomla/Mambo module that allows you to put an email subscription form on each page of your website. The subscription list works with GetResponse.com, an affordable and user-friendly email service provider. You can sign up now for free, and get free email marketing tutorials (more…)