WordPress.org

Ready to get started?Download WordPress

Forums

Javascripts in WordPress...Please help! (21 posts)

  1. mechietechie
    Member
    Posted 8 years ago #

    Hi!
    I found a javascript for a menu structure that looks perfect for my site. I wanted to implement this http://simplythebest.net/scripts/DHTML_scripts/dhtml_script_83.html

    Ive tried numerous things, but i cant manage to get it to work. I can get it to work fine on my html pages, but when editing the php "Theme Editor" in wordpress, i cant get it to work.
    Any thoughts? Thanks!

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    When editing themes to add stuff like that, remember that the purpose of the theme is just to generate the resulting page for the browser. So always work based on what the browser is seeing. Use the View Source on your website to see what is actually making it to the browser. This is helpful in theme editing, especially for javascript which is not running in the theme, but running on the final webpage.

  3. mechietechie
    Member
    Posted 8 years ago #

    Thanks for your response.
    I've looked at the source, and it displays the code the way it shud...it also does that on the site (http://simplythebest.net/scripts/DHTML_scripts/dhtml_script_83.html) where i found the code.

    If you take a look at the way the menu shud look, the red box and the title next to it are all you see at first...on my site, the only thing that comes up is the title...the red box is missing. From this i can assume that for some reason the style tags are not being read properly.
    any thoughts?
    thanks

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    Unless you post the site where you're trying to put this in, there's no way anybody will be able to look at what you've got and help you out.

    Best I can say is to look closer at your CSS.

  5. mechietechie
    Member
    Posted 8 years ago #

    Thats a darn good idea:

    http://mechietechie.com/wp/

    you can see where the menu shud be in the sidebar on the right...

    also, if you visit the site in IE, you'll notice a huge alignment error, that doesnt occur in firefox...still trying to figure that one out...any thoughts on that are also welcome!

    ill keep sifting through my CSS (http://mechietechie.com/wp/wp-content/themes/frametheme/style.css)
    , but i cant find any bugs in it yet (im sure there are)

  6. mechietechie
    Member
    Posted 8 years ago #

    nope, cudnt find anything wrong in my CSS...any thoughts?

  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    I took a look but the resulting html is way over my head. There is some complex stuff going on there. Everything looks good to me except I'm not certain about the position: absolute in the CSS.

    You might try making it work on a test page all by itself and see if you can get it working there. Just a thought.

  8. mechietechie
    Member
    Posted 8 years ago #

    Thanks for taking the time!
    I did make a test page, just copied the neccesary text, and it worked fine as html. not sure wut else to do

  9. Samuel B
    moderator
    Posted 8 years ago #

    Unless you scale down some of the images in your main container your sidebar will never perform correctly. Adjust the images to a size slightly smaller than your main container size and odds are your code will start working. Also, it's a good idea to wrap your javascript with <div> tags.
    <div>javacode</div>

  10. mechietechie
    Member
    Posted 8 years ago #

    thanks samboll, that might help with the IE alignment. i did mess around with the pixel numbers a bit, and havent had a chance to re-do that...but on the template i started from, the picture was proportional, so it shud cause so much of a problem

  11. mechietechie
    Member
    Posted 8 years ago #

    hmm, ive been thru everything, and cant seem to figure it out.

    any more thoughts?

  12. Dreamchaser
    Member
    Posted 8 years ago #

    Hi There,

    This should fix your solution WordPress JavaScript Plugin for Posts : http://www.acmetech.com/blog/2006/03/19/wordpress-javascript-plugin/

    Example over @ http://www.renewedreflections.com/bmi-calculator-body-mass-index/ ( You can checkout Michael’s Body Mass Index Calculator JavaScript within a WordPress post. )

    Though this plugin was intended for AdSense Integration, the actual work of the plugi is to display javascript on the sites and hence you javascript should work perfectly!

    Have Fun :)

    - Dreamchaser

  13. mechietechie
    Member
    Posted 8 years ago #

    hey dreamchaser
    thanks for the effort, but this is for posts, will it work out for the template? i think part of the problem is that the code refers to definitions in the style sheet, and it seem that thos arnt being read.
    thanks
    anyother thoughts?

  14. mechietechie
    Member
    Posted 8 years ago #

    ive tried everything, and at this point im fairly certain ther's an solely an issue in reading the style sheet. any thoughts on how to resolve that?

  15. mechietechie
    Member
    Posted 8 years ago #

    no luck yet for me...anyone else??

  16. pizdin_dim
    Member
    Posted 8 years ago #

    I notice that your page output is not valid XHTML:

    http://validator.w3.org/check?uri=http%3A%2F%2Fmechietechie.com%2Fwp%2F

    It's possible that the W3C validation service doesn't know how to ignore javascript, so I'm not sure if that's the reason for the errors. Try taking the javascript out and re-validate again.

    EDIT: Just tried accessing your page using Firefox 1.5 and I get lots of errors in the javascript console. A sample follows:

    Error: Unknown property 'filter'. Declaration dropped. Source File: ttp://mechietechie.com/wp/wp-content/themes/frametheme/style.css Line: 63

    Error: Error in parsing value for property 'width'. Declaration dropped. Source File: http://mechietechie.com/wp/wp-content/themes/frametheme/style.css Line: 401

  17. mechietechie
    Member
    Posted 8 years ago #

    hey, thanks pizdin_dim!
    I still havent gotten it to work right, but i have gotten a few dots to show up now. but there are still some more bugs!

  18. mechietechie
    Member
    Posted 8 years ago #

    Ok, more help is needed

    The site is now at http://www.mechietechie.com.
    The validator gives a whole bunch of errors in the javascript. Any ideas?

    http://validator.w3.org/check?uri=http%3A%2F%2Fmechietechie.com%2F&charset=%28detect+automatically%29&doctype=Inline

    thanks

  19. pizdin_dim
    Member
    Posted 8 years ago #

    Remove all the javascript code first and then validate. Then fix whatever the output errors you get. Then put the javascript code back in (in the right place). That way you'll know if your page validates. If you're still having javascript errors after that, have you considered contacting the author?

  20. red-star
    Member
    Posted 8 years ago #

    You could take a look at Moo.fx and prototyp to do things like that in WP.
    I use some javascriptfiles in my theme and they work fine. But dont put them in your plugin section. Make a folder in your WP root and name it js. Put there the js files, and make the needed lines in your head section.

  21. mechietechie
    Member
    Posted 8 years ago #

    i found that the problem was the "xhtml" definition at the header. the script is designed for html 4.0. any chance any one here knows what id hafta do to get it working in xhtml?

Topic Closed

This topic has been closed to new replies.

About this Topic