Using Notepad++ - javascript

I'm using Notepad++ to do Javascript, and it doesn't work. This is what comes out in the web page:
, not the actual thing it would display when it runs properly.
I have the notepad++ 6.6.7 version.
Here's how I did it:
Write the code.
Change the language to Javascript.
Run it in Google Chrome.
And this is my result!?!?:
Am I not using Notepad++ correctly or my code has an error in it? Thank you so much!

Rename your file to somefilename.html.

You're saving your file as thing.txt. Save it as thing.html.
Also you're saying that you are working on javascript, but your code only contains html, so even you try to choose the language as javascript, javascript format won't work (but first save it as html file).

Browsers will render HTML and execute JavaScript in HTML documents not text documents as your filename of thing.txt suggests.
If you're experimenting try one of these sites: http://jsbin.com/ or http://jsfiddle.net/

Related

How to embed javascript file content into html page in Thymeleaf?

I need to embed javascript directly into html page generated by Thymeleaf
Something like:
<script th:include="../static/assets/generated/scripts.js"></script>
But this simple usage leads to SAXParseException...
Is there any easy way to switch off parsing of the th:included
content? Or any other way how to embed content of resource int the result page?
I don't think that is possible out of the box. You could probably write an extension that can do it. Or maybe there is an existing one, but I couldn't find one right now.
Does it have to to be a separate JavaScript file? Can't you put your JavaScript code into a fragment and include it like any other fragment?
NB: Including JavaScript into your HTML file like that is usually bad web design und may be a sign that you have bigger problems and you haven't structured your code well. Why do you think you need to do that? Why can't you refer to an external script file?
Thats not a Thymeleaf-Thing. It's classic html:
<script src="/assets/generated/scripts.js"></script>
In version 3.0, you can do it in this way
<script th:src="#{/webjars/jquery/dist/jquery.min.js}"></script>

Export Html table to EXCEL , PDF , Print

I will export my html table to pdf , excel and print
I found this tuto , I try it but not work
I think I missing something
I need help
[tuto link ] https://datatables.net/extensions/buttons/examples/initialisation/export.html
Here is working fiddle
http://jsfiddle.net/3F8ZJ/
Make sure you check the versions.
Make sure to load this CDN's
http://cdn.datatables.net/1.10.0/css/jquery.dataTables.css
http://cdn.datatables.net/1.10.0/js/jquery.dataTables.js
http://cdn.datatables.net/tabletools/2.2.2/css/dataTables.tableTools.min.css
http://cdn.datatables.net/tabletools/2.2.2/js/dataTables.tableTools.min.js
You might study programming skills and make a code.
As an easier way, I introduce an online extracting tool, http://listly.io/.
Copy and Paste your html code, then it extracts the list-like contents.
You can also download Excel file.
Table Tools, that you are using, has now been retired and has been replaced by the Buttons and Select extensions.I wouldn't recommend using it.
Also, try using HTML buttons instead of SWF, unless you have to.
I made some changes to your code, and it is working well. You can see it here!
Note that, i have changed external resources
Also i would recommend using local resources instead of linking to it.

Angular 2 Quickstart: wrong encoding of js files

I'm very new to angular 2, so I'm trying to make this work: https://angular.io/guide/quickstart
The problem which I have really confuses me. All JS files, which I get as a response, have strange encoding - basically, I see a bunch of hieroglyphs. Non-js files (html and css) are ok. Please see below, html is ok. Js - totally not.
Do you guys have any idea, what can it be? Computer culture is not Chinese or Japanese, just in case.
You can use notepad++ or any html editor with encode options available to change the page encoding:
Open your file with Notepad++
Go to "Encoding" menu option in main menu
Select "Convert to UTF-8-BOM"
check if the page display correctly
This can be related to your js files encoding on your editor.

Converting a div content to an image via javascript

How to convert the content of a div tag to an image and save it to a local folder via javascript ? I know there must be a way out but i am unable to find it . Any help would be greatly appreciated . Thanks in advance.
Canvas.drawImage supports Image, Canvas and Video elements. Some people say, that it may support DOMElement in the future.
There are many open-source browsers written in C (or C++). There is Emscripten project, which can convert C++ code to Javascript. So you can run your own browser inside a browser and use it to render your HTML.
Running browser inside a browser is not strange idea at all. E.g. there is a project, that emulates x86 machine in a browser - http://copy.sh/v24/.
Javascript cannot write to the file system if that is what you are trying to achieve.
You can make use of HTML5's localStorage if you need to store strings in javascript but they are sandboxed within the browser.
To get the contents of most HTML elements you can use document.getElementById('theDiv').innerHTML to get what is between the <div></div> tags.
You can pass the result of innerHTML to a PHP page, and from there save it to file.
EDIT
Ok based our comments, I recommend you use PHP. You use document.getElementById('theDiv').innerHTML to send the html to a php page. From there use http://www.rabuser.info/painty.zip Download their 'painty.php' page and pass the html to it. painty.php in theory will generate an img out of the html.

How to delete a file from physical directory with JavaScript (Windows/IE Only)?

I am dynamically generating an HTML file for the print option.
After the print window has been opened and the file printed, I want to remove the HTML file from the folder.
I need to do this with JavaScript. For this I am using the following code:
var myObject = new ActiveXObject("Scripting.FileSystemObject");
var myFolder = myObject.GetFile(strReportFilePath);
myFolder.Delete();`
But this only works in IE but not in Firefox, so how do I delete the file with a JavaScript function?
You can't. JavaScript is sandboxed. With IE, you are using ActiveX to do the dirty work.
I'm on the look out for just accessing files on the local files and failed to find a way that works cross-browser easily yet. However you might want to try signed Java applets which seemed to be a (though not so smooth) solution.
You also might want to keep track of this

Categories