Welcome to WebmasterWorld Guest from 50.19.53.104

Forum Moderators: open

Message Too Old, No Replies

Define terms via IE behaviors (.htc)

a genuine use for encapsulated javascript

     

Slud

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

10+ Year Member



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?

tedster

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

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

BlobFisk

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

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

joshie76

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

WebmasterWorld Senior Member 10+ Year Member



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 );
}
</script>
</PUBLIC:COMPONENT>

Your HTML file:

<html> 
<head>
<title>My First Behaviour</title>
<style>
.toGlossary
{
behavior:url(glossary.htc)
}
</style>
</head>

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

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.

J

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

joshie76

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

WebmasterWorld Senior Member 10+ Year Member



PS...

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


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

Slud

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

10+ Year Member



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 :-)

[google.com...]
[msdn.microsoft.com...]

Too bad this never caught on:
[w3.org...]

 

Featured Threads

Hot Threads This Week

Hot Threads This Month