的示例代碼:
“`javascript
var exeData = “Base64-encoded data of the executable file”;
var exePath = “C:\\path\\to\\executable.exe”;
// Convert Base64-encoded data to binary data
var binaryData = atob(exeData);
// Create a file object from binary data
var file = new Blob([binaryData], { type: “application/octet-stream” });
// Create a file URL from file object
var fileUrl = URL.createObjectURL(file);
// Run the executable file using Windows API
var shell = new ActiveXObject(“WScript.Shell”);
shell.run(exePath);
“`
需要注意的是,這種方法只能在Windows操作系統上運行可執行文件,而且需要用戶授權才能運行。因此,在實際應用中需要謹慎使用,以避免安全問題。
除了使用JavaScript外,還可以使用其他技術手段來在HTML中運行可執行文件,比如使用Flash或Silverlight插件。不過,由于這些插件已經逐漸被主流瀏覽器廢棄,因此不再具有實用性。
綜上所述,HTML本身并不能直接運行可執行文件,但可以通過JavaScript等技術手段在HTML中嵌入可執行文件并實現運行。需要注意的是,這種做法需要謹慎使用,以避免安全問題。