Simple Javascript Redirect

I’m not really sure that there is really any good reason to use this but here it is anyway. A simple javascript redirect tutorial for you to Enjoy.

<script type="text/javascript">
<!--
window.location = "http://www.benkaeding.com/"
//-->
</script>

When the script above is placed is is on a page, it automatically redirect the visitor to the new url.

If you would like a little delay so you can let people know that they are being redirected, place the following in the head of your html…

<script type="text/javascript">
<!--
function delayer(){
    window.location = "http://www.benkaeding.com/"
}
//-->
</script>

and add this to your body tag…

onLoad="setTimeout('delayer()', 5000)"

Here’s a simplified html example using the script and a five second delay.

<html>
<head>
<script type="text/javascript">
<!--
function delayer(){
    window.location = "http://www.benkaeding.com/"
}
//-->
</script>
</head>
<body onLoad="setTimeout('delayer()', 5000)">
<h2>Prepare to be redirected to www.BenKaeding.com!</h2>
<p>There will be a 5 second delay before you are redirected to my homepage.</p>
</body>
</html>

Just change the number to whatever amount of time you want (in milliseconds).

Seconds Ago Script using $UNIXTIMESTAMP

I discovered this little post by Alex Whinfield that just made me so happy.  I just know that it will make you happy too. It’s a “Seconds Ago” counter that uses the $UNIXTIMESTAMP php call to calculate a time since.  Works great and is very light. Get the code here.

If In Category – A WordPress Hack

I recently had a need where content needed to be included in a certain blog category and not in others. The content will only display post is in the specified category. You can use the category slug or the category ID.

<?php if (in_category('1')); ?>
<div class='someclass'>
<p>Some Content</p>
</div>
<?php endif; ?>