An update to the Javascript Google technique for Entry Archives

So I did a little more testing, and my original technique as written will not work with Entry Archives. But, with one minor change to the Header template module, things will work just fine.

The default Header template module includes the following bits for the body tag:

<body class="<MTIf name="body_class"><$MTGetVar name="body_class"$> </MTIf><$MTGetVar name="page_layout" default="layout-wtt"$>"<MTIf name="body_onload"> onload="<$MTGetVar name="body_onload"$>"</MTIf>>

Since it specifies the onload property in there, it conflicts with the javascript code that performs the search for google visitors, so I changed it to look like the following:

TC.attachLoadEvent (checkReferer);
<MTIf name="body_onload">TC.attachLoadEvent (function () { <$MTGetVar name="body_onload"$> } );</MTIf>
</script>
</head>
<body class="<MTIf name="body_class"><$MTGetVar name="body_class"$> </MTIf><$MTGetVar name="page_layout" default="layout-wtt"$>">

Pulling the onload code out of the body tag and putting it into an anonymous function seems to do the trick for me.

Enjoy!

No TrackBacks

Всегда приятно, когда при переходишь по ссылке с поисковика и обнаруживаешь на странице искомые слова, которые выделены в тексте. Дэвид Рэйнерс написал, как сделать подобное при помощи одного лишь javascript (обычно используется PHP & MySQL). ... Read More

Leave a comment

About Me

I am a software developer for Six Apart living outside of Baltimore, MD. I have written a number of plugins for Movable Type, including the award winning MultiBlog, which has (as of MT 4) been integrated into the base application....
More...

Recent Entries

  • Minimalist plugins are fun!

    Last night I whipped up one of the smallest plugins I’ve ever written. It is so small in fact that I was able to stuff...

  • Feedburner Widget on MT News

    Movable Type News A WordPress 2.5 Upgrade Guide: And of course there are lots of third-party plugins for the MT dashboard, to integrate statistics and...

  • AD&D Monster Stats for the Presidential Canditates

    Charles Stross (scifi author, D&D nerd, and former perl columnist) posted Politics as she is Played with 3d6: The recent death of Gary Gygax, who...

  • Feedburner Widget 0.3

    At this point, I am really tempted to drop the ‘Widget’ from the name of the plugin, since it is doing so much more...

  • Feedburner Widget 0.2

    So I finally got around to updating the FeedburnerWidget plugin for MT 4.1 (since I finally got around to upgrading my install to MT 4.1)....

Close