spacer spacer spacer

2006-06-06

Typekey, XHTML and Firefox

Several people have complained that they could not make comments on my blog. I eventually tracked this down to Firefox’s strict XHTML interpretation disabling the (somewhat sloppy) Javascript that tries to dynamically generate the comment form. Cleaning up that Javascript was all that it took, although it took me more than an hour to find the bits that needed cleaning.

Here is the relevant code from the individual archive template that I had to change:

<mtentryifallowcomments>

[…]

            <div id="thanks">

Remove (but save) the Javascript that was here. Insert a span with an ID that will hold the commenter’s name, when you know it.

              <p>
                Thanks for signing in, <span id="commenter_name"> </span>. Now you can comment.

[…]

            </div>

Rather than generating the ‘not signed in’ text on the fly, include it here with an ID. We will enable one or the other of these divs in Javascript.

            <div id="nothanks">
              You are not signed in. You need to be registered to comment on this site.

[…]

            </div>

Insert the script that you saved above here. This script retrieves the name of the user if they are logged in to TypeKey.

<script type="text/javascript" src="&lt;MTCGIPath&gt;&lt;MTCommentScript&gt;?__mode=cmtr_name_js"></script>

Replace the script that used to appear here completely. This script uses XML commenting and accessors to insert the user’s name and enable the appropriate message.

<script language="javascript" type="text/javascript">
    // <![CDATA[
    if (commenter_name) {
        document.getElementById('commenter_name').firstChild.data = commenter_name;
        document.getElementById('thanks').setAttribute("style", "display: block");
        document.getElementById('nothanks').setAttribute("style", "display: none");
    } else {
        document.getElementById('thanks').setAttribute("style", "display: none");
        document.getElementById('nothanks').setAttribute("style", "display: block");
    }
    // ]]>
</script>

[…]

Similarly with this script. If you are using TypeKey, the only important bits are whether to remember the URL the user provides or not. (One wonders why that does not come from TypeKey too?)

<script type="text/javascript" language="javascript">
    // <![CDATA[
      document.getElementById('url').setAttribute('value', getCookie("mtcmthome"));
    if (getCookie("mtcmtauth") || getCookie("mtcmthome")) {
        document.getElementById('remember').setAttribute('checked',true);
    } else {
        document.getElementById('forget').setAttribute('checked',true);
    }
    // ]]>
</script>

That’s it!

Comments

Good to see that FF’s rigour isn’t arbitrary.

BTW: I love the way tech_docs brings me into contact with SMEs such as yourself, but … it’s a lot like what jwz said after he read about AutoCollage: “this paper makes me feel very dumb.”

2006-06-08 17:57 | Ben Tremblay

SME?

2006-06-09 16:56 | ptw

Subject Matter Expert, I believe. Hey, I hate to jump in the middle of a good post, but I, too, am feeling quite dumb. Are the setAttribute methods also mandatory for FF? My Javascript in a XHTML strict setting hurts sometimes and I can’t glean the answer. How did you learn what you needed to do besides the old hack and whack method?

2006-12-07 21:11 | Erik

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?


You are not signed in. You need to be registered to comment on this site. Sign in