I need some help with a javascript function

  • Unknown's avatar

    So I have music on my site without using someone else’s plugin. I want to have a tab that shows/hides the lyrics of the song.
    I saw something like that on the theme Black Met White by Tony Street. The code involves something like

    <a href="javascript:sweeptoggle('expand')">Show Navigation</a> | <a href="javascript:sweeptoggle('contract')">Hide Navigation</a></div><div id="menu"><h3 onclick="expandcontent(this, 'sc1')" style="cursor:hand; cursor:pointer"><span class="showstate"></span>Navigation</h3><div id="sc1" class="switchcontent">
    <?php get_sidebar(); ?>

    However, I tried doing something like that and it didn’t work. I’m not very familiar with the php include function so I don’t want to use that. Do I have to? If I do, how do I resolve this problem?
    Btw, here’s my site.

  • Unknown's avatar

    There is no way to solve it. Javascript insertion isn’t allowed in either the text of a post or your sidebar due to security reasons.

  • Unknown's avatar

    Not on wordpress, I’m hosting my blog.
    Javascript should be allowed right?
    It works with the Black Met White theme so there should be a way to do this, right?

  • Unknown's avatar

    You have a WordPress blog (not WordPress.com) and want JavaScript in the posts? Should not be a problem.

    Your method is calling JavaScript functions (“sweeptoggle”, “expandcontent”). I assume you have those defined and either will place them in your HEAD or in an included .js file?

    I think you will NOT be able to use the Visual Rich Text Editor when creating a post that includes JavaScript. That can be turned off via Users > Your Profile.

    If you’re putting the JavaScript in the sidebar, the Visual Rich Text Editor won’t matter.

  • Unknown's avatar

    Actually, I havn’t had those defined. Might be the problem.
    How do I define it?

  • Unknown's avatar

    [in the absence of our mod drmike, may I politely suggest this OT discussion be taken to email or the wordpress.org forum. This board is for wordpress.COM support. thanks.]

  • Unknown's avatar

    /me is very sick and very stressed. :(

    Actually this question should be directed over at the support forum where he or she is hosted. It’s not a WP issue.

    I will make the suggestion though that I don’t remember ‘sweeptoggle’ being a part of javascript and I don’t have my cheat sheet handy. Youmight have to declair it within the pages head or within a seperate file and link it in before you can use it.

    Good luck,
    -drmike

  • The topic ‘I need some help with a javascript function’ is closed to new replies.