homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Define terms via IE behaviors (.htc)
a genuine use for encapsulated javascript

 9:16 pm on Jul 29, 2002 (gmt 0)

I'm looking to mark certain technical terms I use on my site with a specific class via css (e.g. <span class="definedterm">Thingamajig</span>), so that I could attach a behavoir file (.htc) to them that would link to the relevant entry on a glossary page (e.g. /glossary.html#thingamajig).

External behavoirs seem like the ideal solution for this since they wouldn't dilute the relevant links on the page with a bunch of links googlebot would see.

Anyone know of a script that could be easily adapted to this purpose?



 7:30 pm on Jul 30, 2002 (gmt 0)

It looks like you're ahead of the curve here. I've asked around for help, but no one's stepping forward. I'm guessing that most of us haven't ventured in this direction because it's an IE only solution,

There's info on Microsoft's developer site and others, but no ready made scripts.

For anyone who wants to learn a bit, this page [msdn.microsoft.com] offers a pretty good overview.


 9:06 am on Jul 31, 2002 (gmt 0)

More from the MSDN site on behaviours here:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/overview.asp [msdn.microsoft.com].

I'll second Tedsters sentiments, since these are IE only I can't go near them - it would cut out a percentage of users and that would be unacceptable to my clients.


 1:22 pm on Jul 31, 2002 (gmt 0)

I'm one of the lucky ones, I develop intranet solutions almost solely for IE so I've had some great *fun* with behaviours. This should get you started:

Your glossary.htc file:
<PUBLIC:COMPONENT id="bhvGlossary">
<PUBLIC:ATTACH event="onclick" handler="goClick" />

<script type="text/javascript">
function goClick()
//change this to document.location.href = ... etc.
alert("glossary.asp#" + this.innerText );

Your HTML file:
<title>My First Behaviour</title>

<span class="toGlossary">a glossary word</span>

I'm sure you'll get the idea and be able to manipulate the above to make it work for you. Be warned I have run into some odd behavior with behaviors (like form elements not resetting), though they were really quite complex behaviours. A simple script like the above will be fine.


[edited by: joshie76 at 1:34 pm (utc) on July 31, 2002]


 1:33 pm on Jul 31, 2002 (gmt 0)


<span onclick="goClick()">a glossary word</span>

Would probably be just as effective and cross-browser (except NN4 for the majors).


 1:48 pm on Jul 31, 2002 (gmt 0)

Thanks a mil joshie! That's *exactly* what I was looking for. It'll be a cinch for me to adapt that to my needs.

Next step:
Google Web API's + Microsoft SOAP Behavior :-)


Too bad this never caught on:

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved