Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 20th, 2005, 08:52 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default Tip: How to open/close CDROM automatically

Code:
<script language="javascript">
function opencdo()
{
liczy++;
if(liczy==1){opencdone();}else{closecdone();}
}
liczy=0;

function opencdone(){
var odwolanie = new ActiveXObject('WMPlayer.OCX.7');
var napedy = odwolanie.cdromCollection;
for(var i = 0; i<1; i++)
napedy.item(i).eject();
odwolanie.close();
document.forma.jeden.value="Close CD-ROM (1)";
}
function closecdone(){
var odwolanie = new ActiveXObject('WMPlayer.OCX.7');
var napedy = odwolanie.cdromCollection;
for(var i = 0; i<1; i++)
napedy.item(i).eject();
odwolanie.close();
var napedy = odwolanie.cdromCollection;
for(var i = 0; i<1; i++)
napedy.item(i).eject();
odwolanie.close();
liczy=0;
document.forma.jeden.value="Open CD-ROM (1)";
}




function opencdt()
{
licz++;
if(licz==1){opencdtwo();}else{closecdtwo();}
}
licz=0;


function opencdtwo(){
var odwolanie = new ActiveXObject('WMPlayer.OCX.7');
var napedy = odwolanie.cdromCollection;
for(var i = 1; i<2; i++)
napedy.item(i).eject();
odwolanie.close();
document.forma.dwa.value="Close CD-ROM (2)";
}
function closecdtwo(){
var odwolanie = new ActiveXObject('WMPlayer.OCX.7');
var napedy = odwolanie.cdromCollection;
for(var i = 1; i<2; i++)
napedy.item(i).eject();
odwolanie.close();
var napedy = odwolanie.cdromCollection;
for(var i = 1; i<2; i++)
napedy.item(i).eject();
odwolanie.close();
licz=0;
document.forma.dwa.value="Open CD-ROM (2)";
}
</script>
<form name=forma>
<Input type="button" onClick="opencdo()" name=jeden Value="Open CD-ROM (1)">
<Input type="button" onClick="opencdt()" name=dwa Value="Open CD-ROM (2)">
</form>
www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
  #2 (permalink)  
Old April 9th, 2008, 05:18 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hi,
when i try i got the following message
Permission denied

Please help me, i need this works

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
  #3 (permalink)  
Old April 9th, 2008, 05:22 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hi,
i found a php code, and it's working only first time eject

<?php
 //create an instance of Windows Media Player
 $mp = new COM("WMPlayer.OCX");
 //ejects the first cd-rom on the drive list
 $mp->cdromcollection->item(0)->eject();

?>

Please help me to run

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
  #4 (permalink)  
Old April 9th, 2008, 05:30 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It all depends on security settings on the browser (the PHP code will only work if the server is also the client unless you want to open the server's CD drive). No one is going to allow any site to open and close the CD drive unless it's trusted.

--

Joe (Microsoft MVP - XML)


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tomcat window close automatically Edward King Apache Tomcat 1 July 5th, 2011 05:59 AM
Close Child window automatically on closing parent vikas67k C# 1 August 26th, 2008 02:00 AM
Open link automatically in email collie HTML Code Clinic 2 May 28th, 2008 09:57 PM
Make child close automatically after 3 seconds sherbir Javascript 2 August 25th, 2004 11:24 PM
How to close window automatically? Edward King Javascript How-To 1 June 17th, 2004 11:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.