I am trying to use JQuery to embed Haloscan comments (http:// www.haloscan.com) on a webpage.
Normally, one would hardcode the Haloscan reference code in the HTML just under a hardcoded comment. Then one includes the Haloscan javascript underneath the message, with the unique identifier to the message as a parameter: <p>My cat message here</p> <div><a href="javascript:HaloScan('cat');" target="_self"> <script type="text/javascript">postCount('cat');</ script> </a> | <a href="javascript:HaloScanTB('cat');" target="_self"> <script type="text/javascript">postCountTB('cat'); </script> </a></div> I am trying to replace all of the javscript with a simple <a> tag that I can manipulate with JQuery at page load time to set the javascript dynamically. <!-- here is my main body code --> <div><a href="haloscan_cat" target="_self">haloscan_cats</a></div> <!-- here is the code I insert in the head portion of the page --> <SCRIPT type=text/javascript> //<![CDATA[ $(document).ready(function() { // examine each hyperlink. For each hyperlink with an href beginning with "haloscan_", strip // off the "haloscan_" prefix and execute the haloscan functions using the remainder of the href string // as the param. The param serves as the message key to haloscan. var sHaloscan_string = "haloscan_"; $('a').each(function(){ var sHref = $(this).attr("href").toLowerCase(); if (sHref.indexOf(sHaloscan_string) == 0) { sHref = sHref.substr(sHaloscan_string.length); var sNewHTML = "<a href=\"javascript:HaloScan('" + sHref + "');\" target=\"_self\">" + "<script type=\"text\/javascript\">postCount('" + sHref + "');< \/script></a>"; $(this).html(sNewHTML); $(this).click(); } }); }); //]]> </SCRIPT> The problem is that I can't seem to execute the postCount() function by creating the new HTML and invoking the "click()". The postCount() is supposed to return a string that represents the number of comments that have already been made on that post. Any ideas on how I can get the postCount() to execute once I set the new HTML? Thanks experts!