Load script if not index.php Load script if not index.php
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Load script if not index.php

Started by Sweetener, February 10, 2019, 01:29:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sweetener

I want to load this:

<script>
$(document).ready(function () {
    $('html, body').animate({
        scrollTop: $('#scroll').offset().top
    }, 'slow');
});</script>


When its not the index, so the users can skip the header in desktop/mobile devices automatically.
Is there anyway to do that?

ron4mac

Why not just don't show the header when the condition is met?

At any rate...
You could put this somewhere in the theme.php file of your theme:
if (basename($superCage->server->getRaw('PHP_SELF')) != 'index.php') {
  echo '
<script>
   $(document).ready(function () {
      $("html, body").animate({scrollTop: $("#scroll").offset().top}, "slow");
   });
</script>
';
}