BillyRayPreachersSon
Programmer
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
dummyBehaviour.sct
testHarness.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 (
), it returns as-is, and if you execute the
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
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
Code:
<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
Code:
<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
Code:
<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 (
Code:
.prop
Code:
showProp()
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