I’ve got a fever, and the only prescription is more cowbell.

Intense Debate and the Base Tag

After installing Intense Debate comments on my company’s blog, I noticed some unexpected behaviors while trying to login to Intense Debate from their comments thread.  Upon clicking either login link, I was redirected to {baseUrl}/#idc-container.  Either I had to remove the base tag from the site, thus having to change every url to an absolute url, or create a way around this using javascript.

Originally, I did remove the base url and create absolute urls for everyting.  However, this created problems with creating relative links in the cms.  I did create a way to fix that, but eventually I would turn back and go another route to fix the problem involving the base tag.

The original problem lay in the code inside of the showLogin function, which is what the href pointed to for logging into intense debate on the comments thread.  The problem is when this function calls window.location = “#idc-container”.

function showLogin()
{
  $id("IDCommentsHead").className = $id("IDCommentsHead").className.replace(/idc-signup/g, "").replace(/idc-openid/g, "").replace(/idc-openid_signup/g, "") + " idc-login";
  $id("IDCommentsHeadLogin").className += " idc-sel";
  //$id("IDCommentsHeadSignup").className = $id("IDCommentsHeadSignup").className.replace(/idc-sel/g, "");
  window.location = "#idc-container";
  $id("IDtxtLoginEmail").focus();
};

I inserted the following javascript, with jquery, to fix this problem.  I created my own showLogin replacement function titled showLoginFixed.  I replaced the window.location with an abolute url.  I created a function to get both of the login links and replace their href with “javascript: showLoginFixed();”.  I also created an interval so that we can keep checking to see if intense debate has loaded yet, because I can’t replace the href’s on those links until they exist on the page.

var checkIdInterval = "";
function showLoginFixed() {
  $id("IDCommentsHead").className = $id("IDCommentsHead").className.replace(/idc-signup/g, "").replace(/idc-openid/g, "").replace(/idc-openid_signup/g, "") + " idc-login";
  $id("IDCommentsHeadLogin").className += " idc-sel";
  //$id("IDCommentsHeadSignup").className = $id("IDCommentsHeadSignup").className.replace(/idc-sel/g, "");
  //change from a relative url to an absolute url
  window.location = "{absoluteUrl}#idc-container";
  $id("IDtxtLoginEmail").focus();
};

function fixShowLogin() {
  $("#IDCommentsHeadLogin, #IDCPostNav li a[href*=showLogin]").each(function() {
    $(this).attr("href", "javascript: showLoginFixed();");
    clearInterval(checkIdInterval);
  });
}

checkIdInterval = setInterval(fixShowLogin, 1000);

This solution makes the login links work the way they normally would without the user noticing that anything has gone wrong.  There was some collaberation about this problem on GetSatisfaction.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

3 Comments to Intense Debate and the Base Tag

  1. July 3, 2009 at 10:00 pm | Permalink

    Nice fix! Sorry you had to hack around our problem. If it's any consolation I think this is fixed for others as of today by replacing
    window.location = '#idc-container';
    with
    window.location.hash = '#idc-container';
    Which should already by live.

    If you'd prefer not to poll to check when IntenseDebate loads, we offer some JavaScript hooks to detect that via our plugin system. There's more info here: http://www.intensedebate.com/docs/plugin-resource... but the basic idea is that you can register a JS function that we will fire on certain events (including IntenseDebate loading). Might be a slightly nicer solution if you're interested in poking around.

    Again, sorry for the trouble, but nice job working around it!

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe

Search

You Can Find Me On ...

Categories

RSS Other Articles By Me

  • reCAPTCHA: Blocking Spam and More
    A few months ago, I developed a ColdFusion/Mach-II implementation of the reCAPTCHA API.  This type of CAPTCHA requires the person to enter two words rather than a single sequence of random letters.  In addition to protecting your website from spam, reCAPTCHA helps digitize text books.  They do this by using a mystery word as one of the two words, until there […]
  • Using Friendfeed to Automatically Post Your Blog Entries on Twitter
    Friendfeed is a feed aggregator that groups together updates from twitter, facebook, digg, youtube, your blog and much more.  It can also publish entries from your friendfeed to twitter.  This article shows you how to tap into that twitter publishing feature of friendfeed to automate the posting of your blog entries to twitter.  Watch my screencast to create […]
  • Intense Debate Now on the Sitepro Blog!
    Recently on the Sitepro Blog, we have switched to using an enhanced commenting system called Intense Debate.  Intense Debate provides many features that will supercharge the community, increase comments, and increase pageviews.  Some notable features include commenter profiles, reputation scores, email notifications, reply by email, and facebook integration. […]
  • Sitepro Developers Attend TCCFUG
    Last Thursday, a few Sitepro developers attended the Twin Cities Coldfusion User Group at University of St. Thomas.  We were introduced to the future of Coldfusion, specifically Coldfusion 9.  There was free admission, free food, free shirt, prizes, and an abundance of new Coldfusion features. […]