0


Recently I've started to learn some information about .hta files, which can build a basic apps without using a browser (because I'm using only pure javascript and need to get all powers of the processor and RAM to calculate some big data).
So, when I'm trying to open an .hta app it says me:

An error has occurred in the script on this page
Line: 69
Char: 13
Error: Expected ";" Code: 0

There is what I have on this line:

for (let i = 0; i < 10000; i++) {

And it's not a first page with the same code and same error.
Some useful information:

  • Yes, I have HTA:APPLICATION in the head tag.
  • The script is located in the end of the body tag.
  • All HTML and CSS code inside were successfully loaded.
  • I made an .hta file by 2 ways: with 'Save As' in Sublime Text 3 and easily by changing it's extension in the path (using Windows 10).
user692942
  • 16,398
  • 7
  • 76
  • 175
  • Small point but worth mentioning, if you are using a HTA you are using JScript not JavaScript. Its a small but noticable difference. – user692942 Nov 28 '18 at 01:05
  • 1
    It doesn't like `let` because it wasn't introduce [until ECMAScript 6](https://stackoverflow.com/questions/762011/whats-the-difference-between-using-let-and-var-to-declare-a-variable-in-jav#comment12716276_762011) when JScript in it's final browser version (IE 9) was based on ECMAScript 5. – user692942 Nov 28 '18 at 01:18
  • @Lankymart Okay, I see now. It seems like a lot difference in syntax. Can you advice me some ways to create an app with working pure javascript and html but without frameworks such as Node.js? – Eugene Zolotuhin Nov 28 '18 at 01:20
  • @Lankymart I've changed a let to the var and it works now. Thank you for your advice. And one more question (if it isn't boring for you): now I get a problem with 'setAttribute' of creating an element each time. How to do it through ECMAScript 5, pls? – Eugene Zolotuhin Nov 28 '18 at 01:29
  • 1
    I would go through the [ECMAScript 5 spec](https://www.ecma-international.org/ecma-262/5.1/) and see what is available. Pretty sure that `getAttribute()` is a DOM method not specific to ECMAScript though. – user692942 Nov 28 '18 at 09:57
  • @EugeneZolotuhin A big help when working with legacy techniques, like IE and HTA, is [CSS Compatibility](http://msdn.microsoft.com/en-us/library/hh781508(v=vs.85).aspx) and also [JavaScript Version Information](http://msdn.microsoft.com/en-us/library/s4esdbwz(v=vs.94).aspx) at MSDN. But as Lankymart said, the said setter is a DOM method, it has nothing to do with JS version, you might want to ask a new question about that. – Teemu Nov 29 '18 at 14:47
  • @Teemu Yes, only one question ;) Is there a way to run .js files without browser (to use all the PC powers)? – Eugene Zolotuhin Nov 30 '18 at 20:54
  • Maybe you should take a look at [PowerShell](https://learn.microsoft.com/en-us/powershell/) ..? If you want pure JScript, then C/WScript and wsf files are still available. Note, that these are old technologies using also old JScript versions, i.e. ~ ES3. – Teemu Nov 30 '18 at 21:14

0 Answers0