×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

IE Behaviours (.htc vs .sct)

IE Behaviours (.htc vs .sct)

IE Behaviours (.htc vs .sct)

(OP)
Hi all...

I'm trying to fathom out the difference between using X-Scriptlet (.sct) files and HTML Component (.htc) files with IE behaviours.

I can include identical code in both formats, with only the interface changing, and they both function in exactly the same way.

I had previously been told that X-Scriptlets allowed you to override default HTML properties (things like 'disabled', etc), whereas HTML Components did not - but this appears not to be the case.

I know that you can also include X-Scriptlets on the page using OBJECT tags, but at the moment, I'm just interested in the differences between the formats when used as behaviours.

Can anyone tell me the difference between the two formats? Are there any limitations with one over the other? Is one faster, better, less CPU intensive, etc etc etc? I'm struggling to find any differences myself.

Here's a quick test-harness to show the identical code in both formats:

dummyBehaviour.htc
<public:component>
    <public:property name="prop" get="get_prop" put="put_prop" />
    <public:method name="showProp" />

    <script type="text/javascript">
        var _prop = '';
        function get_prop()           { return (_prop);             }
        function put_prop(paramValue) { _prop = paramValue;         }
        function showProp()           { alert(_prop.toUpperCase()); }
    </script>
</public:component>


dummyBehaviour.sct
<scriptlet>
    <implements type="behavior" default />
    <implements type="automation">
        <public:property name="prop" get="get_prop" put="put_prop" />
        <public:method name="showProp" />
    </implements>

    <script type="text/javascript">
        var _prop = '';
        function get_prop()           { return (_prop);             }
        function put_prop(paramValue) { _prop = paramValue;         }
        function showProp()           { alert(_prop.toUpperCase()); }
    </script>
</scriptlet>


testHarness.html
<html>
<head>
<style type="text/css">
span.htc { behavior: url(dummyBehaviour.htc); }
span.sct { behavior: url(dummyBehaviour.sct); }
</style>
</head>

<body>
    <span class="htc" id="dummyHTCspan" prop="dummy htc property value">htc span</span>
    <br>
    <span class="sct" id="dummySCTspan" prop="dummy sct property value">sct span</span>
    <br><br>

    Click <a href="javascript:alert(document.getElementById('dummyHTCspan').prop);">here</a> to display property 'prop' (htc)
    <br>
    Click <a href="javascript:document.getElementById('dummyHTCspan').showProp();">here</a> to execuite 'showProp()' method (htc)
    <br><br>
    Click <a href="javascript:alert(document.getElementById('dummySCTspan').prop);">here</a> to display property 'prop' (sct)
    <br>
    Click <a href="javascript:document.getElementById('dummySCTspan').showProp();">here</a> to execuite 'showProp()' method (sct)
</body>
</html>


The code above doesn't do anything too fancy - it's just a demo to illustrate including behaviours on the page. It lets you set and get the value of the "prop" property. If you get it by name (.prop), it returns as-is, and if you execute the showProp() method, it alerts it in uppercase.

Documentation on MSDN seems to be sketchy, and a lot of it is now out of date. Much of what is lying around on the 'net seems not to use the interface format that I have above, so I can't really compare differences.

Any help in finding differences between the two formats will be greatly appreciated.

Thanks in advance!

Dan

RE: IE Behaviours (.htc vs .sct)

(OP)
Hmm..

I managed to find only one difference so far - you cannot use HTML comment tags in .sct files to hide the scripting... So using:

<script type="text/javascript">
<!--
     ....
//-->
</script>


Would fail to run any of the script. The .htc file seemed to have no such limitation.

But still, I cannot seem to find any real differences between the formats ;o(

Dan

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close