...

View Full Version : can you open the cd drive with j script



narf
12-20-2003, 06:22 PM
can you open and close the cd drive with javascript



or how can you reverse a word

ive tried using char at and index of but failed.

fredmv
12-20-2003, 06:35 PM
Originally posted by narf
can you open and close the cd drive with javascript Yes. However, it only works in IE since it uses ActiveX objects along with the Windows Meda Player API to do it. I got the original (VBScript) version here (http://www.waxy.org/archive/2003/03/27/open_cdr.shtml) and converted it to JavaScript.
<script type="text/javascript">
//<![CDATA[
var oWMP = new ActiveXObject("WMPlayer.OCX.7"), colCDROMs = oWMP.cdromCollection;
if(colCDROMs.Count >= 1) for(i=0; i<colCDROMs.Count; i++) colCDROMs.item(i).eject();
//]]>
</script>
Originally posted by narf
or how can you reverse a word
<script type="text/javascript">
//<![CDATA[
String.prototype.reverse = function()
{
return this.split('').reverse().join('');
}

alert('foo'.reverse());
alert('bar'.reverse());
//]]>
</script>

swmr
12-20-2003, 06:56 PM
:eek: that's good to know, fredmv...

The Shell Object can also be used to open a drawer:





<html>
<head>
<script type="text/JScript">
function ShellEjectCD(){
var sAp = new ActiveXObject("Shell.Application");
sAp.NameSpace(17).ParseName("F:\\").InvokeVerb("e&ject");
}
</script>
</head>
<body>
<button onclick="ShellEjectCD()">test</button>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum