Drupal - Detect front page in Drupal 6 with javascript

Generally Drupal adds a "front" class to the body element of whatever page is acting as the front page. If your theme's page.tpl.php is printing the body classes (i.e <body class="<?php echo $classes; ?>"), which it most likely is (it should), then your javascript can check if the body element has the "front" class.

So, assuming jQuery (because Drupal includes it) then you'd do:

if ($('body').hasClass('front')) { // do stuff...}

Tags:

Javascript