Reputation: 862
I know the .htaccess file can do all forms of magic. I have folders that have video files in them and would like clicking the file to open them within a html5 video tag in the same browser window. What would be the easiest way to accomplish this?
It's important to note that I do not have access to server side scripting. I assume that the following should be possible in one way or another:
Read the names of the files in the current directory from the DOM, since the filenames are listed in the HTML generated by Apache.
Add some form of event handler to the filename links.
Use jQuery or whatever to generate an overlay div with the video tags when a file is clicked.
I couldn't find anything that works directly with google, but I assume I'm not the first one that tries to do something like this.
Upvotes: 0
Views: 321
Reputation: 417
You can use jQuery to do a AJAX GET request and get the Apache Directory Listing. You can put this list into a container and add some custom events on the links, for example.
Something like this:
$.get("/dir/with/apache/listing/", function(data) {
var directoryListing = $(data);
// Add to a container or something
$("#VideoList").append(directoryListing);
$("#VideoList a").on("click", function(ev) {
ev.preventDefault(); // Stop default action (download)
alert($(this).attr("href")); // Video link
return false;
});
});
Please note that AJAX requests only work on the same domain. It would also require you to create some sort of a page to put this script on.
Upvotes: 1