Results 1 to 2 of 2

Thread: Quote Comment - WordPress Help

  1. #1
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Quote Comment - WordPress Help

    Hello -

    I'd like to make it so, when someone clicks a link that says "Quote" in a comment on my wordpress blog, they get it in the <blockquote> tag.

    This is what I have so far:

    JavaScript:

    Code:
        <script type="text/javascript">
    	//<![CDATA[
        function Quote(commentID,author,commenttext) {
    		var Quote='<blockquote> By <a href="#comment-'+commentID+'">'+author+'</a>:<br><br>'+commenttext+'</blockquote> ';
        	var myField;
            if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') {
        		myField = document.getElementById('comment');
        	} else {
        		return false;
        	}
        	if (document.selection) {
        		myField.focus();
        		sel = document.selection.createRange();
        		sel.text = Quote;
        		myField.focus();
        	}
        	else if (myField.selectionStart || myField.selectionStart == '0') {
        		var startPos = myField.selectionStart;
        		var endPos = myField.selectionEnd;
        		var cursorPos = endPos;
        		myField.value = myField.value.substring(0, startPos)
        					  + Quote
        					  + myField.value.substring(endPos, myField.value.length);
        		cursorPos += Quote.length;
        		myField.focus();
        		myField.selectionStart = cursorPos;
        		myField.selectionEnd = cursorPos;
        	}
        	else {
        		myField.value += Quote;
        		myField.focus();
        	}
       	}
    	//]]>
        </script>
    HTML Link:
    Code:
    <a href="#" onclick='Quote("<?php comment_ID() ?>", "<?php comment_author(); ?>", "<?php comment_text() ?>")' title="Quote this Comment">Quote</a>

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    OK... What problems are you having?
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

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
  •