SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using JavaScript in Wordpress

    Hey,

    I am trying to use JavaScript in my wordpress theme for the navigation bar.

    I have tested this code out in an index.html file and it works fine, it is basically a dropdown menu.

    Now i am using a wordpress theme and as you know i have to split the pages up into 4 files. In my header.php file i have the following code:-

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>

    <script type="text/javascript" src="chromejs/chrome.js">

    </script>


    <!--[if !IE]><!-->
    <style type="text/css">@import 'firefox.css';</style>
    <!--<![endif]-->

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />

    </head>
    <body>
    <div id="page">
    <div id="header">
    <div class="chromestyle" id="chromemenu">
    <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="#" rel="dropmenu2">About Us</a></li>
    <li><a href="#" rel="dropmenu3">Food &amp; Drink</a></li>
    <li><a href="blog" rel="dropmenu4">News</a></li>
    <li><a href="#" rel="dropmenu5">Contact Us</a></li>
    </ul>
    </div>


    <!--2nd drop down menu -->
    <div id="dropmenu2" class="dropmenudiv" style="width: 150px;">
    <a href="intro.html">Introduction</a>
    <a href="">Our location</a>
    <a href="">Links and partners</a>

    <a href="">Awards</a>
    <a href="">Sustainability</a>
    <a href="">Videos</a>
    </div>

    <!--3rd drop down menu -->
    <div id="dropmenu3" class="dropmenudiv" style="width: 150px;">
    <a href="">Media clips</a>
    <a href="">Producer diarys</a>
    <a href="">Hotelier of the month</a>

    <a href="">Events</a>
    <a href="">Recipe ideas</a>
    <a href="">Sustainability</a>
    </div>

    <!--4th drop down menu -->
    <div id="dropmenu4" class="dropmenudiv" style="width: 150px;">
    <a href="">Media clips</a>
    <a href="">Producer diarys</a>
    <a href="">Hotelier of the month</a>

    <a href="">Events</a>
    <a href="">Recipe ideas</a>
    <a href="">Sustainability</a>
    </div>

    <!--4th drop down menu -->
    <div id="dropmenu5" class="dropmenudiv" style="width: 170px;">
    <a href="">Enquiry form</a>
    <a href="">Feeback</a>
    <a href="">Recommend retail outlet</a>
    </div>

    <script type="text/javascript">

    cssdropdown.startchrome("chromemenu")

    </script>


    <div id="title">Latest News</div>

    </div>
    <!--/header -->

    But when i load my page up it shows the error at the bottom left of the browser and does not work?

    Does anybody know why?

    Thanks
    Regards

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by billy_111 View Post
    But when i load my page up it shows the error at the bottom left of the browser and does not work?
    First of all, I think you've posted in the wrong forum. This isn't a blogging question (although WP is a blog application), but a programming one.
    Second, what error shows at the bottom left of your browser?

  3. #3
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    sorry i thought because it is related to WP i was meant to post it here (I'm a new member you see)

    Anyway in IE i clicked on the error and it says the following:-

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30618)
    Timestamp: Wed, 22 Jul 2009 09:30:38 UTC


    Message: 'cssdropdown' is undefined
    Line: 74
    Char: 1
    Code: 0
    URI: http://www.listentotheconstituents.com/mey/blog/

  4. #4
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And by the way line 74 is this line:-

    cssdropdown.startchrome("chromemenu")

  5. #5
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Are you sure it finds the chrome.js?
    Because your blog has url: mey/blog
    and the js file is found at mey/chromejs/chrome.js
    Maybe you should change the include of the js file in
    Code:
    <script type="text/javascript" src="/mey/chromejs/chrome.js">
    </script>

  6. #6
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    That dont seem to be working either, the error itself is directed at the chromemenu line which is 74, i dont understand why it does not work..

    In my index.html file which i tested the menu i had the same code..

    All the files i have is in one folder, and then i have a chromejs folder where the javascript files are, therefore the code should work

  7. #7
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    If all your files are in one folder, then maybe you're using some kind of url rewrite rule?
    I'm still convinced that the problem lies in the js file not being found. But if it is, then it should be a js problem. You should ask an admin or mod to move this thread to the JS forum.

  8. #8
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks il try to sort it out..

    Regards


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •