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...
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"...
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...
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...
Write a simple text-formating.cpp file that reads (asks for then reads) a text file and produces...
Write a simple text-formating.cpp file that reads (asks for then reads) a text file and produces another text file in Which blank lines are removed, multiple blanks are replaced with a single blank, and no lines are longer than some given length (let say 80). Put as many words as possible on the same line (as close as possible to 80 characters). You will have to break some lines of the given file, but do not break any words or...
Write a C++ program to create a text file. Your file should contain the following text:...
Write a C++ program to create a text file. Your file should contain the following text: Batch files are text files created by programmer. The file is written in notepad. Creating a text file and writing to it by using fstream: to write to a file, you need to open thew file as write mode. To do so, include a header filr to your program. Create an object of type fsrteam. Open the file as write mode. Reading from a...
Can someone verify why my code isnt running <!DOCTYPE html> <html> <body bgcolor=aqua text=purple> <script type="text/javascript">...
Can someone verify why my code isnt running <!DOCTYPE html> <html> <body bgcolor=aqua text=purple> <script type="text/javascript"> funtion oldMacVerse(animal, sound) //Assumes: animal is the name of an animal, sound is the sound it makes //Results: displays a version of the song "Old MacDonals Had a Farm" in outputDiv { document.getElementById('outputDiv').innerHTML =    '<p>Old MacDonald had a farm, E-I-E-I-O.<br>' +    'And on that farm he had a ' + animal + ', E-I-E-I-O.<br>' +    'With a ' + sound +...
modify code to write the output as an HTML table to a file in the output...
modify code to write the output as an HTML table to a file in the output directory. The file that is saying to work at : SOURCE CODE IN PERL: print "Enter principal amount: "; $P=; while($P<=0) { print "Principal must be positive. Try again: "; $P=; } print "Enter number of times interest is applied in a year: "; $n=; while($n!=12 && $n!=4 && $n!=2 && $n!=1) { print "It must be 12, 4, 2 or 1. Try again:...
BEFORE html <html> <head>       <link rel="stylesheet" type="text/css" href="mystyle98_d.css"> </head> <body>              <p>  
BEFORE html <html> <head>       <link rel="stylesheet" type="text/css" href="mystyle98_d.css"> </head> <body>              <p>     I'm a paragraph, what color am I ?      </p>    <ul>      <li id = "fix"> I'm a list item;what color am I? </li>        </ul> <div class = "central1"> <p class ="above"> I'm a paragraph; what color am I? </p>      <p>     I'm another paragraph, what color am I ?      </p>    <ol>      <li id = "fix1"> I'm another list item;what...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT