I am usinf Filzilla Client to view/edit FTP files on my server I am able to open and edit HTMLn PHP, and CSS Files using Notepad++ or Brackets Editor but on JavaScript files I am getting this error
the js Files icons also looks different than Notepad++ or Brackets Editor which are like bwlow
Can you please let me know why this is happening?
I have set "custom editor" & check "always use defualt editor" then working for me.
https://i.stack.imgur.com/ZmDLl.png
By default the View/Edit command in FileZilla opens the file in an application associated with the file type. While you have the editor associated with .php/.css, you have a WSH runtime associated with .js, so the JavaScript files get executed.
You can override the default behavior by going to Edit > Settings > File editing.
Related
I am trying to make a JS program using a text file on the client side. The thing is that it was difficult to find out how to do such a basic functionality because it is not a desired feature. I want to open a text file which is not in the local directory of a user but in the directory with the html file. So, what I want is the JS version of this code (which is in python)
# Open a file
fo = open("foo.txt", "wb")
fo.write( "Python is a great language.\nYeah its great!!\n");
# Close opend file
fo.close()
Thanks!
You can read a file with FileReader() (as a result of a user selecting files) but fortunately we can't modify client's or server's files with JavaScript in client side (there is no FileWriter()). To do that, you should upload the file to the server (through Ajax or a simple html form) and modify it with server side code.
I have a set of JavaScript files in 'src' folder compiled by Closure Compiler in a single file cw-around.js in 'src/comp' with generated source maps cw-around.js.map also in 'src/comp'.
"//# sourceMappingURL=xxx" is at the end of the compiled file cw-around.js.
xxx being a full HTTP link (local web server) to cw-around.js.map and being successfully tested in a browser.
{"version":3,"file":"cw-around.js" is the beginning of the cw-around.js.map file
In the Dev mode/sources file list, I can see the associated files in Chrome and Firefox (when I put a wrong xxx, I can see only the compiled cw-around.js file).
There, when I double click on an associated file (cw-demodata.js, one of the JavaScript file name that was included in the compiled file):
In Chrome 58 or 61 ("JavaScript source maps enabled" + "source map detected"), an empty code window is displayed.
In Firefox 54 ("show original sources" + "devtools.source-map.locations.enabled;true"), the HTML code of my calling web page is displayed.
What's wrong? How to investigate to identify what's wrong?
I just had the very same issue, and it came from sourceMapLocationMappings not correctly set. In the source map, there is (alongside "version" and "file") a "sources": [] entry, that tells the browser where the actual source file (not the source map) is to be found.
As I, like you, compiled the assets from a subfolder, the subfolder path was inside this sources array (i.e. it was "sources": ["src/comp/foo.js"] instead of "sources": ["foo.js"]). The browser tried to request src/comp/foo.js from my webserver, and it obviously wasn't there, because foo.js was there directly.
The solution to this is to set up proper sourceMapLocationMappings. Using the closure-compiler cli, you do that with --source_map_location_mapping "\"src/comp/foo.js^|foo.js\"". Using the ant task, you add a sourceMapLocaionMapping="src/comp/foo.js|foo.js" to the task call.
This adjusts the "sources" to point to ["foo.js"] directly, which is then served by your webserver and can be found by the dev tools.
Edit: added double quotes in --source_map_location_mapping according to http://stackoverflow.com/a/29542669
I found a solution to my issue: to compile the js files and generate the source map in the same directory as the js files. The associated js files are now properly displayed in both Chrome and Firefox.
Previously, after successfully opening the compiled js file and the source map, it seems that the browser was unable to find and load the non compiled js files.
It would have been great to have an error message in the console to quickly spot the problem...
I logged in to my FTP from Filezilla and tried to open a JS file, and it gave me the following error:
Script: C:/.../slider.js
Line: 1
Char: 1
Error: 'document' is undefined
Code: 800A1391
Source: Microsoft JScript runtime error
I have jQuery linked to the .php file as well...'document' comes from:
$(document).ready(function() {
//Code is here...
});
I tried downloading the file and opening it, I tried removing the $(document).ready();, I tried removing jquery (which by the way, when I opened the jQuery file it gave me the same almost the same error). Any help is appreciated. Thanks!
EDIT:
One of the tags for this post was "asp.net", but to be honest I don't even know if it is related to asp.net...
I had the same issue and fixed it by doing the following in Filezilla:
Go to Edit > Settings
Go to the 'File editing' section
Under 'Default Editor': Ensure that Notepad++ is selected as your custom editor
Change the radio button from 'Use filetype associations if available' to 'Always use default editor'
You say that you're right clicking and clicking "View/Edit", and it throws that error.
The error is occurring because Windows is executing the script, and the script has a problem (because it relies on another script being loaded).
So although you may be clicking "View/Edit", and expecting that this will open the file in Notepad++, what it is actually doing is assuming that "View" means "Run the script".
Clearly, Notepad++ is not the default action for this file type, or at least it isn't according to Filezilla. Maybe the default action isn't actually set the way you think it is, or maybe it's Filezilla that isn't respecting your default action.
The solutions:
If Filezilla has an option "Open with..." that allows you to pick the program to open the file with, then use that and select Notepad++ manually. Even better, if it has the option to then make that the default, then tick it, and the problem should be solved permanently.
Alternatively, just download the file to your local machine before trying to open it.
I got this working in FileZilla by doing the following: -
Edit -> Settings
File editing -> Use custom editor [file path to notepad ++] then
|___File editing -> Filetype associations
Adding the line -> js "C:\Program Files (x86)\Notepad++\notepad++.exe"
Click OK to save changes
This will stop windows script host from attempting to run the file and open in notepad++.
While the question has effectively been identified previously in the post I hope that someone finds this 'how-to' useful.
This is not a programming problem. It's a file association problem - Windows is trying to execute your .js file instead of opening it in an Editor.
See this question on SuperUser: running-javascript-files-js
There's also some explanation of the error here.
Check your file associations again. Try restarting your machine. You will get more help if you ask this type of a question on SuperUser.
It's worked for me after adding the file association.
Edit -> Settings
File Editing -> Select Use filetype association if available checkbox.
Select Filetype Associations -> add association here
js "C:\Program Files\Sublime Text 3\sublime_text.exe"
OK
Note: change association according to your text editor application.
Just follow these steps. It is an easy one to do. Change the default file type for opening the js files.
Edit -> Settings
File editing -> Filetype associations
Adding the line -> js "C:\Program Files(x86)\Notepad++\notepad++.exe"
That's it. Finally, Click OK to save changes.
It will work afterwards.
I am writing a Javascript code. In which I have to open an XML file with QTReport.exe. QTReport.exe is made up of to read the xml file and to show the QTP execution results. I am able to do the following in windows explorer. I did, right click on an XML file and choose the option "Open with" and specify the program as "C:\Bin\QTReport.exe".
My question is, is there any API or function that I can specify as open an XML file with QTReport.exe?
Use the following command line arguement with the qtreport.exe:
bin_dir\qtreport.exe -r path_to_xml_file
I used the Shaun Inman's method to create a customized "upload file" button, and it works just fine.
Trouble is, this method doesn't display the file path that the user has uploaded.
Can anyone help me with a simple JS code to have the file path displayed when selected.
Newer versions of browsers do not send up the file path for security reasons, that is why you are not seeing it.
IE8 value depends on security zone