2.0.0 • Published 7 months ago
hta-drop-target v2.0.0
hta-drop-target
make a drag & drop target on HTML Application (HTA), which can recieve a file or folder path from Windows Explorer.
mechanism
it uses a WebBrowser Control as a drop target. When the control get a dropped file, it trys to navigate to the path of the file, and fires several events with parameter include the path.
requirement
Windows XP or later
installation
download hta-drop-target.js and load it from your HTA file.
<script src="hta-drop-target.js"></script>
npm:
or if you are developping HTA apps in typescript, npm package is available.
npm install hta-drop-target
import HtaDropTarget from "hta-drop-target";
Usage:
sample code
sample.HTA
<body bgcolor="silver">
<div id="container" style="border:4px double red; width:320px; height:240px;">Drag any file to here</div>
<script src="hta-drop-target.js"></script>
<script>
// need a local html file as a target(its content is shown in the target by default)
var htmlPath = 'target.html';
// a container element for the target element
var container = document.getElementById('container');
new HtaDropTarget(htmlPath, {
// drop darget will be built in the container element
container: container,
// ondrop event handler to recieve the file path
ondrop: function(path) {
alert(path);
}
});
</script>
</body>
API Document
under construction.