Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2003
    Location
    ireland
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    can you open the cd drive with j script

    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.
    hello says narf
    and narf says hello

  • #2
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 and converted it to JavaScript.
    Code:
    <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
    Code:
    <script type="text/javascript">
    //<![CDATA[
    	String.prototype.reverse = function()
    	{
    		return this.split('').reverse().join('');
    	}
    	
    	alert('foo'.reverse());
    	alert('bar'.reverse());
    //]]>
    </script>
    Last edited by fredmv; 12-20-2003 at 08:04 PM.

  • #3
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that's good to know, fredmv...

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



    Code:
    <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>
    hmm... ?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •