Question

In: Computer Science

An HTML file is a text file that contains text to be displayed in a browser...

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)

Solutions

Expert Solution

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.


Related Solutions

Write an HTML file for a web page that contains the items below. Use an internal...
Write an HTML file for a web page that contains the items below. Use an internal style sheet to specify all fonts, sizes, colors, and any other aspects of the presentation. Your page should contain the following items: 1) A header with white text on dark green background (just for the header, not the entire page), in Impact font, bold, and centered. 2) Two paragraphs of text, each with dark gray text in Tahoma font, on a light blue background,...
Consider a text file that you will create named “employees.txt”. The file contains data organized according...
Consider a text file that you will create named “employees.txt”. The file contains data organized according to the following format:John Smith 10 15Sarah Johnson 40 12Mary Taylor 27 13Jim Stewart 25 8For instance, “John” is the first name, “Smith” is the last name, “10” is the number of hours per week, and “15” is the hourly rate.Write a program that computes the weekly salary of each employee. The program prints the first name, last name, and weekly salary of each...
take the following html code and make it work for html validator. heres the ,html file...
take the following html code and make it work for html validator. heres the ,html file <!DOCTYPE html> <html lang="en">    <head>        <title> GettingStarted</title>        <meta charset="utf-8">        <link href="Style.css" rel="stylesheet">    </head>       <body>        <header><h1>GettingStarted</h1></header>        <nav>               <b>        <a href="Home.html">Home</a>&nbsp;        <a href="GettingStarted.html">Getting Started</a>&nbsp;        <a href="MaterialsNeeded.html">Materials Needed</a>&nbsp;                      <a href="TroubleShooting.html">TroubleShooting</a>&nbsp;        <a href="InfoMaterials.html">Infomation on materials</a>&nbsp;   ...
<!DOCTYPE html> <html> <body> <!-- replace the text below with your name!--> <!-- --> <!-- -->...
<!DOCTYPE html> <html> <body> <!-- replace the text below with your name!--> <!-- --> <!-- --> <title> TYPE YOUR NAME HERE</title> <script> // // A bug collector collects bugs every day for five days. Write a function that keeps // a running total of the number of bugs collected during the five days. The loop // should ask for the number of bugs collected for each day, and when the loop is // finished, the program should display the total...
how to creat Create a text file that contains a list of integer numbers separated by...
how to creat Create a text file that contains a list of integer numbers separated by comma (numbers.txt). E.g. 3, 7, 5, 1, 11, 8,2, 6 2- how to Write a python program (minMax.py) to read the file numbers.txt and find the largest and smallest numbers in the file. (without using use min(), max()). calculate the average and output the results. 3-Use python file i/o, write a python program (fileCopy.py) that makes a copy of minMax.py (Read contents of minMax.cp...
Using form events functions to answer this question. Use the attached form html file which contains...
Using form events functions to answer this question. Use the attached form html file which contains 2 html radio buttons. When the first choice is chosen, display the text ”First” under the first choice. When the second choice is chosen, display the text ”Second” under the second choice. Here is my HTML code <!DOCTYPE html> <html> <head>     <title>midterm exam</title>     <link rel="stylesheet" href="css/q1.css" /> </head> <body>     <div id = "page">        <form>           <input type="radio"...
How to do in C++ HTML Converter Create a program that reads an HTML file and...
How to do in C++ HTML Converter Create a program that reads an HTML file and converts it to plain text. Console HTML Converter Grocery List * Eggs * Milk * Butter Specifications Your instructor should provide an HTML file named groceries.html that contains these HTML tags: <h1>Grocery List</h1> <ul>     <li>Eggs</li>     <li>Milk</li>     <li>Butter</li> </ul> When the program starts, it should read the contents of the file, remove the HTML tags, remove any spaces to the left of the tags, add...
A hotel salesperson enters sales in a text file. Each line contains the following, separated by...
A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the client, the service sold (such as Dinner, Conference, Lodging, and so on), the amount of the sale, and the date of that event. Write a program that reads such a file and displays the total amount for each service category. Use the following data for your text file:5 pts Bob;Dinner;10.00;January 1, 2013 Tom;Dinner;14.00;January 2, 2013 Anne;Lodging;125.00;January 3, 2013 Jerry;Lodging;125.00;January...
Whats the code to open a text file and every line in that text file that...
Whats the code to open a text file and every line in that text file that starts with # then it should delete that line In python using .strip
Convert this C++ to js/html and run in browser. ///////////////////////////////////////////////// #include <cstdlib> #include <ctime> #include <sstream>...
Convert this C++ to js/html and run in browser. ///////////////////////////////////////////////// #include <cstdlib> #include <ctime> #include <sstream> #include <iostream> using namespace std; /* * */ class Dice{ private: static const int MAXDICE=6; static const int MINDICE=1; int faceVal; public: Dice(int); void setFace(int); int getFace(); string toString(); }; Dice::Dice(int faceVal) { if(faceVal<MINDICE&&faceVal>MAXDICE) { setFace(1); } else { this->faceVal=faceVal; } } void Dice::setFace(int faceVal) { this->faceVal=faceVal; } int Dice::getFace() { return faceVal; } string Dice::toString() { stringstream ss; ss<<faceVal; string str="face value is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT