Javascript: Connecting html and js files - javascript

I'm tring to understand how to connected my html with another file js, but the issues is with this software call topsytle4 it a trail basic,but for some reason it show the file but no feature can be us that could be use.

Add this line between <head> and </head>:
<script src="your_js_path_here"></script>

Related

How to use a a library module in a front-end external javascript file?

Situation:
I have a server side running with express.js and there I get data from SQL database. I would like to show this data to the client side, by sending it to the client.
In the front-end, I need to take this data and make it into a chart. It is possible to do it with the tag in the HTML and include the Plotly library, which I want to use. However, I would like this operation to be done in a separate file, an external JS script for client. This avoids hard-to-read code in the HTML.
The problem is, how can I import Plotly to the external front-end file and use it?
I hope I understood your need correctly :
One simple option would be to include both of your script in your html related document with the one required by the second one first :
...
<script src="path script 1" />
<script src="path script 2 depending on script 1" />
so in your case using CDN :
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="path of your script where you use ploty"></script>
PS:
Also just a proposition but did you thing about importing Ploty in your js backend and use it in your front-end ? or with post/get or with socket ?
Well, simply load it from a CDN :) That's what CDNs are here for
<script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.33.1/plotly-basic.min.js">

Flask Application not returning javascript contents in html

I have a little problem here with my flask application
i have this html file that i have linked to some javascript files and if i open the html file with a browser it works fine with the javascript codes.
Now if i use python flask and return the html file,only the html file is popped up while the JS part is not reflecting on the Web page?
I have linked my JS files to the html page and they are in the same folder
any solutions?
head>
<script src="jquery-1.11.3.min.js"></script>
<script src="video.js"></script>
<script src="zxing.js"></script>
</head>
You should create a new folder titled "Static". Inside that folder is where you store all your CSS files, JavaScript files, etc. So move your video.js, zxing.js and any other JavaScript file to the "Static" folder. Hope this helps, feel free to ask any questions!

Server Side Processing to Cluster the content (or prevent the content) of View Page Source on Browser

I have a simple website with some basic scripts just like this:
<html>
<head>
<title>Welcome to my website but a user can view page source --oops</title>
<script>
//some basic javascript codes i used to build the website
</script>
</head>
<body>
<p>More contents on the actual implementation of the website.<p>
</body>
</html>
Is there a way I can use server side processing technique to cluster the contents of view page source as I have tried using javascript bt no substantial outcome. Please assist!
You can't hide javascript, html, or css from users. You can proccess out in server like php some code but you need to return html. The only way to complicate user's reading of your code, you try minimize javascript/css/html code. YUI compressor can help you:
http://refresh-sf.com
This makes your code more difficult to read, but the behaviour is the same.
Good luck.

WebStorm There is no locally stored library

I'have been working on a project which totally works on jsfiddle.net . However, when i try to run this project in webStorm, i get two errors.
first :
second :
Before, i post my question here, i searched on stackoverflow but couldn't find any solutions. I already did :
libraries:
and my html codes :
<!DOCTYPE html>
<html>
<head>
<title>Super Mario!</title>
<link rel='stylesheet' type='text/css' href='myMario.css'/>
<script type='text/javascript' src='//code.jquery.com/jquery-1.11.2.min.js'></script>
</head>
<body>
<img src="http://i1061.photobucket.com/albums/t480/ericqweinstein/mario.jpg"/>
</body>
</html>
why did u get these errors although i loaded libraries and succesfully defined source script in my html ? what should i do ?
You need to select this file link and click Alt + Enter to download this file to your library.
Screen from WebStorm:
Seems that you get the error when running your .js file directly, via 'Run file_name.js' in it's right-click menu, right? When doing this you are running it using Node.js. But 'document' can't be used in server-side scripts executed by Node.js. It is only defined in client-side javascript, i.e. when running in the browser via a tag in the rendered HTML, not the Javascript API engine running on the server. BTW, your .js file is not even included in your HTML page, as far as I can see from HTML code snippet...
This is not actually an error... WebStorm can't use remote resources available through CDN links for completion. Once it 'sees' such links, it searches for the corresponding library in ~.WebStorm9\system\extLibs\, and, if matching library is not found, prompts you to download it by showing this warning.
You can either suppress this warning or agree to download the library: hit Alt+Enter and then either hit the right arrow and choose 'Suppress for tag' or hit Enter to download.

JavaScript Ajax calls using YUI

Does anybody know if the order of linked external JavaScript files ever matters?. I've never known so but with YUI it seems to be the case when linking library files.
I am making HTTP get Ajax requests, using YUI and I have this HTML file and these 4 files linked (last is my Ajax file and the first 3 are library files from the framework downloaded from the build folder)...
<html>
<head>
<title>Ajax get page with YUI........</title>
<script src="yahoo-min.js"></script>
<script src="event-min.js"></script>
<script src="connection-min.js"></script>
<script src="ajax.js"></script>
</head>
<body>
<h3>Mike's Wednesday Ajax get page........</h3>
<div id="info">
This text will be replaced by Ajax dynamically........
</div>
</body>
</html>
If I link the library files in any other order, the call fails and I get errors. I'm just wondering as new to Ajax and YUI and as I've said, I've never experienced this before.
Thanks in advance.
If you stick with YUI 2, I would advice you to use the dependency configurator there: http://developer.yahoo.com/yui/articles/hosting/
It will tell you what files to include and in what order.

Categories

Resources