Support » Plugins » Hacks » JS in main page

  • mynde

    (@mynde)


    Hello community im really stuck with this thing , maby you can help me out.
    I’m trying to add a small piece of java script from this project – http://introjs.com/ to main main page that is running on buddypress , i was trying to add it in my header.php , index.php and so on , but no luck so far, as you can allready tell im a total beginner. this is the code that i need to add

    <script type="text/javascript">
    $(function(){
      var introguide = introJs();
      // var startbtn   = $('#startdemotour');
    
      introguide.setOptions({
        steps: [
        {
          element: '.nav-bar',
          intro: 'This guided tour will explain the Hongkiat demo page interface.<br><br>Use the arrow keys for navigation or hit ESC to exit the tour immediately.',
          position: 'bottom'
        },
        {
          element: '.nav-logo',
          intro: 'Click this main logo to view a list of all Hongkiat demos.',
          position: 'bottom'
        },
        {
          element: '.nav-title',
          intro: 'Hover over each title to display a longer description.',
          position: 'bottom'
        },
        {
          element: '.readtutorial a',
          intro: 'Click this orange button to view the tutorial article in a new tab.',
          position: 'right'
        },
        {
          element: '.nav-menu',
          intro: "Each demo will link to the previous & next entries.",
          position: 'bottom'
        }
        ]
      });
    
      introguide.start();
    
    });
    </script>

    where should i put this? , P.s my website is http://l2adr.com

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Andrew Nevins

    (@anevins)

    Forum moderator

    Replace this:

    <script type="text/javascript">
    $(function(){

    With this:

    <script type="text/javascript">
    $ = jQuery;
    $(function(){

    mynde

    (@mynde)

    Thank you Andrew , and where should i paste this code ? If if paste it into my header.php it screws up the whole theme

    Moderator Andrew Nevins

    (@anevins)

    Forum moderator

    As it sounds like you’re using a standard theme (as opposed to a custom one), I would recommend using a plugin to handle your JavaScript: https://wordpress.org/plugins/custom-css-js/

    When you enter your JavaScript into that plugin, make sure you remove these bits:

    <script type="text/javascript">
    </script>

    Moderator Andrew Nevins

    (@anevins)

    Forum moderator

    In that plugin, use the settings;
    “External File”
    “Footer”
    “In Frontend”

    mynde

    (@mynde)

    Thank you so much! Going to try it right away

    mynde

    (@mynde)

    Well, might be strange , but still it does not work, and websites js stops responding , atleast i think so, or CSS maby . Button responsible for colapsing menu isnt responding anymore. 😕 😕 P.s i am using boss theme for buddypress

    Moderator Andrew Nevins

    (@anevins)

    Forum moderator

    Weird, maybe keep trying “custom js” plugins until you find one that works. I can’t investigate why your theme does this because it’s a commercial theme.

    mynde

    (@mynde)

    Thank you for the feedback, i was thinking maby there is a way to just add it manually ? Since i just need it in one page i can aswell do it by hand..

    Moderator Andrew Nevins

    (@anevins)

    Forum moderator

    That’s fine for now, but not something we can support you with because of the nature of a commercial theme. We don’t know how it works.

    mynde

    (@mynde)

    Ok, well , i might aswell try and go another way, thank you again for the support !

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘JS in main page’ is closed to new replies.