I have a folder in D:\testDownload .I want to open the folder on click of a button. How to place the code inside the javascript function.
function open(){
}
I have a folder in D:\testDownload .I want to open the folder on click of a button. How to place the code inside the javascript function.
function open(){
}
If you want to simply browse to the location you can just use window.location = 'd:\\testDownload'
. Most browsers will allow you to browse local discs. This is just the equivalent of typing that URL in the address bar.
But this will only work for your specific case on your local machine. It is not possible to do anything like this in the context of the web. For starters, you don't know where peoples' download locations are, you can't guarantee that they allow file browsing (what about mobile browsers etc).
If you want to open an Explorer window, then you're out of luck.
EDIT: Travis Pessetto is wrong. This works, served from the local disk.
<html>
<body>
<script type="text/javascript">
function test() {
window.location = "/tmp/"
}
</script>
<a onclick="test()">click me</a>
</body>
</html>
It isn't possible due to security reasons as seen on this question Open local folder from link. You may be able to do it using a Java applet, but not with JavaScript.
It would also be not that grate of a solution as Mac and Linux do not use drive-letters and it is possible Windows users don't use the same drive letter.