knimbus Posted May 25, 2006 Share Posted May 25, 2006 What I want to do is create a page were you click on a button and it will open you cd rom drive, is this possible to do in either of the two above scripting languages?if so, can someone give me the code for it please? Link to comment Share on other sites More sharing options...
scott100 Posted May 25, 2006 Share Posted May 25, 2006 Javascript with ActiveX/embedded objects (which means IE only) <html> <head> <title>Eject</title> <script type="text/javascript"> <!-- function EjectAll(){ // Eject all CD-ROM drives var col=Player.cdromCollection, c=0; alert(col) while(c<col.count)col.item(c++).eject(); } //--> </script> </head> <body onload="EjectAll()"> <OBJECT ID="Player" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="display:none" width="245" height="240"> </OBJECT> </body> </html> Link to comment Share on other sites More sharing options...
justsomeguy Posted May 25, 2006 Share Posted May 25, 2006 That's kind of mean. I'm surfing around, rocking out to my sweet CD, load some page and all my disks jump out? Bah! Link to comment Share on other sites More sharing options...
knimbus Posted May 25, 2006 Author Share Posted May 25, 2006 lol, I actually kinda want it to annoy someone, or I could do a pop up which says something like "click here for a free cupholder instantly" clicks button and cd tray cmoes out :)actually, scott, do you know how I can edit the code to do that? could you maybe put a few more comments in through the script as I am fairly new to javascript? Link to comment Share on other sites More sharing options...
snowboard01 Posted May 25, 2006 Share Posted May 25, 2006 Annoying people is rude and disrespectful and the ajax might get you kicked off a web server. Count me in! Link to comment Share on other sites More sharing options...
scott100 Posted May 25, 2006 Share Posted May 25, 2006 actually, scott, do you know how I can edit the code to do that?<{POST_SNAPBACK}> <html> <head> <title>Eject</title> <script type="text/javascript"> <!-- function check(){ var answer=confirm("Do you require an instant cup holder?"); if(answer)EjectAll();}function EjectAll(){ // Eject all CD-ROM drives var col=Player.cdromCollection, c=0; while(c<col.count)col.item(c++).eject(); } //--> </script> </head> <body onload="check()"> <OBJECT ID="Player" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="display:none" width="245" height="240"> </OBJECT> </body> </html> Link to comment Share on other sites More sharing options...
knimbus Posted May 25, 2006 Author Share Posted May 25, 2006 Javascript with ActiveX/embedded objects (which means IE only)<html> <head> <title>Eject</title> <script type="text/javascript"> <!-- function EjectAll(){ // Eject all CD-ROM drives var col=Player.cdromCollection, c=0; alert(col) while(c<col.count)col.item(c++).eject(); } //--> </script> </head> <body onload="EjectAll()"> <OBJECT ID="Player" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="display:none" width="245" height="240"> </OBJECT> </body> </html> <{POST_SNAPBACK}> wait, I think I got it, I changed it to this:<html> <head> <title>Eject</title> <script type="text/javascript"> <!-- function EjectAll(){ // Eject all CD-ROM drives var col=Player.cdromCollection, c=0; alert("Click ok for a free cup holder instantly" ) while(c<col.count)col.item(c++).eject(); } //--> </script> </head> <body onload="EjectAll()"> <OBJECT ID="Player" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="display:none" width="245" height="240"> </OBJECT> </body> </html> that seems to work, however, how do I insert 'working' bold tags (<b> m </b>) inside my message? Link to comment Share on other sites More sharing options...
knimbus Posted May 25, 2006 Author Share Posted May 25, 2006 Can you explain the while(c<col.count)col.item(c++).eject(); for me please? Link to comment Share on other sites More sharing options...
scott100 Posted May 25, 2006 Share Posted May 25, 2006 Can you explain thewhile(c<col.count)col.item(c++).eject(); for me please? <{POST_SNAPBACK}> I think it's counting how many cd drives the pc has, then it opens them allyou have used alert, that means that it will always pop out. At least use a confirm so that they have the choice, like the one i posted.I don't think you can change the style of the text in an alert box Link to comment Share on other sites More sharing options...
knimbus Posted May 25, 2006 Author Share Posted May 25, 2006 oh, can you not? I thought you could but oh well, thats that... now I just have to figure out the same but to close the tray, and then I will put the open and close in an infinite loop to annoy my friends mwahaha... Any idea on that? Link to comment Share on other sites More sharing options...
snowboard01 Posted May 25, 2006 Share Posted May 25, 2006 Alot of computers only have the function to open the tray. Take laptops for example the tray is on a spring so it can open but you have to push it closed. One thing you could do is make the tray open when you close it or somthing but I don't think a loop is posible. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 25, 2006 Share Posted May 25, 2006 You can just loop the open command, so that every time they close it it re-opens. If you do that though, insert a 1-second wait or something in the loop, it doesn't need to try to open the CD-ROM 500 times per second. Link to comment Share on other sites More sharing options...
Little Goat Posted May 25, 2006 Share Posted May 25, 2006 if you eject twice, it will go back in.LG Link to comment Share on other sites More sharing options...
justsomeguy Posted May 25, 2006 Share Posted May 25, 2006 That's not true, ejecting twice doesn't do anything. You can open My Computer and right-click on a CD drive and select Eject to test it for yourself. Link to comment Share on other sites More sharing options...
knimbus Posted May 25, 2006 Author Share Posted May 25, 2006 Right, to recap...I want to make the tray open, i can do that... I want to make it so as when the tray is closed, it re-opens...The ideas I have as how to do this (but i dont know the code for it) is to either somehow (if possible) to check if the tray is open and if not then to open it.ORHave the alert box (or confirm box) to appear the first time the page is displayed and after it has been clicked once, they answer is 'saved' and the browser refreshes every say, second and automatically opens the tray because it sees that the answer to the box is already 'ok' or 'yes' Link to comment Share on other sites More sharing options...
knimbus Posted May 25, 2006 Author Share Posted May 25, 2006 justsomeguy, I think your suggestion would work but I don't know how to or where to put the code for a loop with one second delay in, could you show/tell me please? Link to comment Share on other sites More sharing options...
Little Goat Posted May 25, 2006 Share Posted May 25, 2006 ok, I made it so when you click the button it does it. I clicked the button twice, and it went back in.anyway, about the opening and closing, you don't want to do that, cause it ties up the compuer and you cant close the window(at least on my computer).LG Link to comment Share on other sites More sharing options...
snowboard01 Posted May 25, 2006 Share Posted May 25, 2006 Ya thats you destop computer. Im sure that script is going to magically re build my laptop so that there is a motor in the cd drive instead of a spring. It will only work for ie users who use destop cd drives Link to comment Share on other sites More sharing options...
knimbus Posted May 25, 2006 Author Share Posted May 25, 2006 justsomeguy, I think your suggestion would work but I don't know how to or where to put the code for a loop with one second delay in, could you show/tell me please?<{POST_SNAPBACK}> hence this, Can smoeone show me how to do this? Link to comment Share on other sites More sharing options...
SFB Posted May 25, 2006 Share Posted May 25, 2006 this is a funny script. I do agree with justsomeguy that it would be mean to just open someone's cd drive. too bad this doesnt work in more browsers. I didnt think this would actually work but i tested it and it does. this is interesting. Link to comment Share on other sites More sharing options...
knimbus Posted May 25, 2006 Author Share Posted May 25, 2006 lol, it might seem mean but it is strictly friends only, just as a joke, are you able to show me the code with the delayed loop included? Link to comment Share on other sites More sharing options...
scott100 Posted May 25, 2006 Share Posted May 25, 2006 to loop it and drive me nuts <html> <head> <title>Eject</title> <script type="text/javascript"> <!-- function EjectAll(){ // Eject all CD-ROM drives var col=Player.cdromCollection, c=0; while(c<col.count)col.item(c++).eject(); } //--> </script> </head> <body onload="window.setInterval('EjectAll()',1000)"> <OBJECT ID="Player" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="display:none" width="245" height="240"> </OBJECT> </body> </html> Link to comment Share on other sites More sharing options...
knimbus Posted May 25, 2006 Author Share Posted May 25, 2006 THANKS!out of intrest is it possible to minimise the browser window after the tray opens? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 25, 2006 Share Posted May 25, 2006 I don't think you can minimize, but you can always do this:window.resizeTo(1,1);Also, since this only works in IE, you might want to include some code that checks for IE before showing the popup.And lastly, give a link when you're finished. There are several people I want to send to that page. Link to comment Share on other sites More sharing options...
scott100 Posted May 25, 2006 Share Posted May 25, 2006 <html> <head> <title>Eject</title> <script type="text/javascript"> <!-- function EjectAll(){ // Eject all CD-ROM drives var col=Player.cdromCollection, c=0; while(c<col.count)col.item(c++).eject(); } //--> show=1function minimize(){ moveBy(2000,2000) show=0}</script> </head> <body onload="window.setInterval('EjectAll()',1000);minimize();"> <OBJECT ID="Player" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="display:none" width="245" height="240"> </OBJECT> </body> </html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now