Support » Fixing WordPress » How to add Java Script to comments page?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Some reads from here might help maybe:

    Not sure if ya read that already..but, worth a shot right? =)


    Spencerp, the following is from that link you gave me:

    “To use Javascript repeatedly within your site, you can either set the call for the Javascript, or the script itself, in the head of your header.php template file, between the meta tags and the style sheet link, no differently than you would if you were using Javascript in any HTML page. To “load” the Javascript file into your site, in the head, add something like this”

    Does this mean that if I paste my java script in the head, without a call to it, it will work?

    Regards Tezzer

    Well, what I was doing before.. was, added the call to it like such (In the header.php):

    <script type="text/javascript" src="/scripts/updatepage.js"></script>

    Then, in my theme’s file(s).. added the CALL CODE FOR that specific javascript stuff also.. I’ll have to find an example once.. Since my hard drive crash Two weeks ago.. I lost alot of my stuff.. Let me try and find it once.. In the meantime, maybe someone else can help ya..


    Ok, here’s what I had done before, of course.. this is an example ONLY.. so, please keep this in mind lol..

    I had made a main Javascript file, for various javasript stuff, just inside ONE file. Here’s from a theme’s header.php file of mine..

    <!-- JavaScripts -->
    <script language="javascript" type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/javascripts/scripts.js"></script>

    In that: /javascripts/scripts.js file, I had for the Quote Comment plugin:

    /* Quote comment
    function quote(comment, author) {
    theContent = document.getElementById(comment).innerHTML;
    theContent = theContent.replace(/ /g, "");
    theContent = theContent.replace(/<p>/g, "");
    theContent = theContent.replace(/</s*p>/g, "n");
    theContent = theContent.replace(/<br>/g, "")

    if (document.getElementById("comment").value == "") {
    document.getElementById("comment").value += "<strong>" + author + "</strong> said: nn<blockquote>" + theContent + "</blockquote>";
    } else {
    document.getElementById("comment").value += "nn<strong>" + author + "</strong> said: nn<blockquote>" + theContent + "</blockquote>";

    Then in the comments.php file, I had this to call for it:

    <?php if (comments_open()) { ?> <a href="#commentform" title="<?php _e('Quote this comment') ?>" onclick="quote('comment-<?php comment_ID() ?>', '<?php echo($comment->comment_author); ?>')"><?php _e('Quote') ?></a> | <?php } ?>

    I hope this helps maybe.. =/


    What if the visitor has JS disabled in their browser? Won’t that affect your counter?

    Thanks, Spencerp, but that seems a lot of work for what I want. I don’t really need my counter on every page (just on my comments pages). I was able to simply cut and paste it into my index and page templates and it works fine there, so all I am really asking for is a way to cut and paste it into my comments pages?

    Regards Tezzer

    Thanks, Spencerp, I think I have solved my problem now. Or at least I think I have. I was able to paste the java directly into my comments template afterall. I am sorry for causing you work.

    I will test it over the next day and see if it works properly.

    Thanks Tezzer

    Hey, it’s ok Tezzer.. It was no trouble at all. ;)=) I hope it works like you want, and let us know how things work too ok? =)


Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to add Java Script to comments page?’ is closed to new replies.