Jens_L 0 Report post Posted March 26, 2006 Hi!I want to let people download .mp3's. But i don't want them tio have to right-click and "Save as". Is there a way with Java Script?Cheers!'Jens Share this post Link to post Share on other sites
Hercco 0 Report post Posted March 26, 2006 You can disable right clicking with Javascript. There are thousands of scripts avaiblable online so there no need to repeat it here. Just search "disable right click" and "javascript" with your favourte search engine. Basically how it works is that it catches all right clicks on the page are and displays a message for example. The idea is just to override the browsers default behaviour (opening the right click menu). You could just have the script doing nothing.However this system is rather fragile. Anyone knowing even slightest of scripting and website design realizes that you implemented the feature with Javascript and by just simply turning off Javascript can do "Save as...".Anyways you can do the thing with Javascipt all though I don't see much point. Share this post Link to post Share on other sites
Jens_L 0 Report post Posted March 28, 2006 Thanks but i don't need to disable the right click.When you left-click a link that is to a mp3, the browser opens it. I want to make the browser download it, or ask the user if he wants to download it.Is there a script for this? Share this post Link to post Share on other sites
minnieadkins 0 Report post Posted March 29, 2006 (edited) Create 2 buttons/images. One for listening, the other for download. Use the javascript below with the download button.For IE 4 + document.execCommand('SaveAs',null,'filename.html')ordocument.execCommand('SaveAs',null,'filename.html') Example code to use in document:<a href="/testmp3.mp3"><img src="/listen.gif" alt="Listen to the mp3!" /></a><a href="#" onclick="document.execCommand('SaveAs')"><img src="/download.gif" alt="Download the mp3!" /></a>I guess that can work. I think you can put an event handler on an anchor tag. Modify it to your liking.Example javascript code came from http://forums.xisto.com/no_longer_exists/ Edited March 29, 2006 by minnieadkins (see edit history) Share this post Link to post Share on other sites
Jens_L 0 Report post Posted March 31, 2006 Thanks!Now I just need to find a way for ma os x and MozillaBut thanks a LOT!!!/ jens Share this post Link to post Share on other sites
Jens_L 0 Report post Posted March 31, 2006 I check the execCommand at [url = [url="http://forums.xisto.com/no_longer_exists/ and the Save As Command Identifier only saves the current Web page to a file. I want to save the mp3 file not the webpage. This is hard... Share this post Link to post Share on other sites
minnieadkins 0 Report post Posted March 31, 2006 You're right. I didn't notice that it only saved the .html document. I tried downloading an image in a test document and it came up with a javascript error. document.image1.exeCommand(.... Apparently document is the only object that supports that function, and it's only for IE. So even if it worked it would be a bad way to do it. I did a little looking and found this thread https://www.daniweb.com/digital-media/ui-ux-design/threads/39611/clicked-link-countdown There's a PHP solution on post # 24 of the thread. There doesn't seem to be a javascript, or simple solution. Sorry for giving you bad javascript. I didn't test it, I just assumed it was a standard function. Something as simple as 'save as' should be easier to implement. -Good luck Share this post Link to post Share on other sites
Jens_L 0 Report post Posted April 3, 2006 Thanks!I checked to forum out. Will try to put that PHP-code into action. Hope it works!But the idea of just zipping them is not bad, very easy...Cheers! Share this post Link to post Share on other sites