In: Computer Science
An HTML file is a text file that contains text to be displayed in a browser and __________ to be interpreted (read) by the browser formatting and styling the document
Both C++ and javascript are computer programing languages; what are their differences?
What HTML tag can let you insert javascript in to document
Which attributes of the <script> tag tells the brorwser what kind of scripting language is insterted? (give an example)
in the javascript section of the HTML file, how can you write informatipm to the webpage? (give an example)
When an HTML document is read by a suitable Web browser specifically designed to understand HTML codes, such as Internet Explorer or Firefox, the formatting codes are interpreted and the text is displayed in an attractive and more dynamic way. HTML documents can include graphics, and, more importantly, links to other documents.
C++ looks like C with extra things, but in reality it's a different language. It's quite similar on the eye, but along with classes it also has templates (which are terrible, by the way), operator overloading, namespaces, 'auto' keyword with different meaning (since C++11), lambdas (since C++11) and a plethora of other things. It can do a lot of things quite efficiently. But unless you spent a lot of time studying and practising it, chances are you'll make a mistake somewhere, or at very least write unreadable code. Because of that trait, it's used only in areas where you absolutely need that kind of efficiency, i. e. operating systems and video games.
Java draws a lot of inspiration from C++ and puts everything into classes. That is, except primitives, they are... well, not really classes. And then there is int.class which... ugh... it had some bad design decisions.It's also the only one of four, I believe, which is completely backwards compatible, all the way to version 1 (please correct me if I'm wrong), which I assume it's the reason why it keeps all of its baggage. But really, since version 2, it has been improving (except generics, which are only slightly less horrible than C++'s templates), and it's now quite stable and portable. There is an ugly corner or two and a couple of things to be aware of (autoboxing, String immutability, regexes), but imho it's the most suitable of them all for large projects which don't need millisecond-performace (it can be very much on par with C++ in long running processes). Oh, I didn't mention JVM, its virtual machine and the reason it can take a second or two to launch, but gets faster the longer it runs, and the only way to make it run pretty much on every platform, without rebuilding the whole project. It's used a lot for server backends and to a lesser extend for desktop apps. A good part of Android and many apps are also written in Java language (but not running standard VM or using the same standard library).
Open up the Notepad or other simple text-editing software. Use the Run Command (Windows key+R), then type notepad and press Enter. It can also be found in Start menu > Accessories > Notepad.
Start a basic HTML document. Include the HTML tags, including the <head> and </head> combination pair as well as the <body> and </body> combination pair. Type all the needed tags to start the page. It should look like this or the below image
Add a script tag to the HTML's head, and let the text editor know that you'd like to use a javascript language to write your HTML's javascript "program". Add a <script language="javascript"> tag in the head. If you want the script to automatically run when the site loads, don't do a function. If you want to call it, do a function. For this example, we will alert the user.
Call up other JavaScript scripts using a JavaScript function, if you know where the script file can be found. Add it a src (stands for "src") property to the script tag and include the complete web address of the file. Make sure to link directly to the Javascript file and not the page's URL where the script is being called from by the other page's creator.
Make sure to end your HTML document. Following the </body> tag, include the </html> tag.
Save your page. Save the page as.html, it will become a web page. Double click on the icon, and watch as your page loads and an alert box comes up.
To insert JavaScript into a web page, use the <script> tag. You should use the type attribute to specify the type of script being used, which in the case of JavaScript is text/javascript. It is also possible to the language attribute to say what JavaScript version you are using. In practice, this number means very little to browsers. They may claim to support a specific version, but will have vastly different capabilities. All JavaScript supporting browsers currently in use will support a level of JavaScript equivalent to JavaScript 1.2 or higher, so this is what I will teach you in this class
Browsers will generally choose an arbitrary version number that they will claim to support, and will run any script that has either no language version number, or a version equal to or lower than the one they claim to support. Since the language is so unreliable, you should generally omit this attribute, although it is common to see scripts using it. Your script can then detect if the browser is capable of running your script, and it can do this a lot more accurately than the version number can.