Wednesday, April 3, 2019
HTML and Javascript Tutorial
hyper school text mark-up row and Javaleger Tutorial hypertext mark-up delivery Basic papersDocument lift goes hereVisible text goes here heading ElementsLargest Heading . . . . . . . . . . . . Smallest HeadingText ElementsThis is a paragraph (line break) (horizontal rule)This text is preformatted discursive StylesThis text is emphasizedThis text is strongThis is some com be sicker codificationPhysical StylesThis text is b olderThis text is italic connectives, Anchors, and Image ElementsThis is a LinkS rest e-mailA named anchorUseful Tips classJump to the Useful Tips SectionUnordered listFirst power point coterminous itemOrdered listFirst itemside by side(p) itemDefinition listFirst termDefinitionNext termDefinitionTablessome head teachersomeheadersometextsometextFramesFormsApplesBananasCherriesEntities is the kindred as is the same as is the same as Other ElementsText quoted from some source. ring 1Address 2CityCommonly Used Character Entitiesnote Entity name be case sensitiveThe Meta ElementAs we relieveed in the earlier chapter, the head member contains general information (meta-information) about a document.hypertext markup language besides includes a meta fixings that goes inside the head element. The purpose of the meta element is to tolerate meta-information about the document.Most often the meta element is go for to provide information that is relevant to web browsers or search engines identical describing the heart and soul of your document.Keywords for assay Engines some search engines on the WWW exit use the name and content attributes of the meta grade to index your varlets.The intention of the name and content attributes is to tell apart the content of a foliate.However, since too many wind vanemasters check used meta chase afters for spamming, the worrys of repeating keywords to give pages a higher ranking, some search engines have stopped using them entirely.Uniform resource LocatorsSomething chated a Unifo rm Resource Locator (URL) is used to address a document (or other data) on the World Wide net. A full Web address like this http//www.w3schools.com/html/lastpage.htm follows these syntax rules arrangement//host. cosmosport/ cartroad/ billnameThe scheme is formation the type of Internet service. The about common type is http.The domain is defining the Internet domain name like w3schools.com.The host is defining the domain host. If omitted, the slight host for http is www.The port is defining the port heel at the host. The port subdue is normally omitted. The default port number for http is 80.The path is defining a path (a sub directory) at the server. If the path is omitted, the resource (the document) essential be located at the root directory of the Web site.The billname is defining the name of a document. The default filename susceptibility be default.asp, or index.html or something else depending on the settings of the Web server.URL SchemesSome lawsuits of the most co mmon schemes quite a little be found belowAccessing a NewsgroupThe following hypertext markup language scratchHTML Newsgroup establishs a unify to a advancedsgroup like this HTML Newsgroup transfering with FTPThe following HTML code transfer WinZipcreates a link to download a file like this Download WinZip.(The link doesnt work. Dont try it. It is just an example. W3Schools doesnt really have an ftp directory.)Link to your Mail systemThe following HTML codeemailprotectedcreates a link to your own mail system like thisInsert a record into HTML PageA script in HTML is outlined with the tag. Note that you go out have to use the type attribute to narrow down the scripting language.How to Handle Older BrowsersA browser that does not recognize the tag at all, ordain display the tags content as text on the page. To pr showcase the browser from doing this, you should hide the script in comment tags. An old browser (that does not recognize the tag) go forth ignore the comment an d it will not spell the tags content on the page, while a new browser will understand that the script should be penalize, even if it is surround by comment tags.ExampleNew to HTML 4.0 is the ability to allow HTML events trigger actions in the browser, like starting a JavaScript when a drug substance abuser clicks on an HTML element. Below is a list of attributes that tail end be inserted into HTML tags to define event actions.Window EventsOnly validated in clay and frameset elements.Only valid in form elements.Keyboard EventsNot valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.Mouse EventsNot valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, title elements.Your Windows PC as a Web waiterIf you indispensableness other people to view your pages, you must publish them.To publish your work, you must save your pages on a weather vane server.Your own PC dissolve act as a clear ser ver if you install IIS or PWS.IIS or PWS turns your com go downer into a web server.Microsoft IIS and PWS are free web server comp unmatchablents.IIS - Internet Information ServerIIS is for Windows system like Windows 2000, XP, and fit. It is also available for Windows NT.IIS is easy to install and ideal for developing and testing web applications.IIS includes Active Server Pages (ASP), a server-side scripting standard that ignore be used to create dynamic and interactive web applications.PWS - Personal Web ServerPWS is for older Windows system like Windows 95, 98, and NT.PWS is easy to install and bay window be used for developing and testing web applications including ASP.We dont recommend running PWS for anything else than training. It is over-the-hill and have security issues.Windows Web Server VersionsWindows Vista Professional comes with IIS 6.Windows Vista shell Edition does not support PWS or IIS.Windows XP Professional comes with IIS 5.Windows XP Home Edition does not support IIS or PWS.Windows 2000 Professional comes with IIS 4.Windows NT Professional comes with IIS 3 and also supports IIS 4.Windows NT Workstation supports PWS and IIS 3.Windows ME does not support PWS or IIS.Windows 98 comes with PWS.Windows 95 supports PWS.HTML SummaryThis tutorial has taught you how to use HTML to create your own web site.HTML is the universal markup language for the Web. HTML lets you format text, add graphics, create links, input forms, frames and tables, etc., and save it all in a text file that any browser posterior read and display.The key to HTML is the tags, which indicates what content is coming up.XHTMLXHTML reformulates HTML 4.01 in XML.CSSCSS is used to control the style and layout of tenfold Web pages all at once.With CSS, all formatting gouge be removed from the HTML document and stored in a separate file.CSS gives you arrive control of the layout, without messing up the document content.JavaScript TutorialWhat is JavaScript?JavaScript was des igned to add interactivity to HTML pagesJavaScript is a scripting languageA scripting language is a lightweight schedule languageJavaScript is usually embedded directly into HTML pagesJavaScript is an interpreted language (means that scripts execute without preliminary compilation)Everyone substructure use JavaScript without purchasing a certifyWhat can a JavaScript Do?JavaScript gives HTML designers a programming weapon - HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax Almost anyone can put small snippets of code into their HTML pagesJavaScript can put dynamic text into an HTML page - A JavaScript report like this document. draw up( + name + ) can write a variable text into an HTML pageJavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML elementJavaScript can read and write HTML elements - A JavaScript can rea d and change the content of an HTML elementJavaScript can be used to validate data - A JavaScript can be used to validate form data onwards it is submitted to a server. This saves the server from extra processingJavaScript can be used to come across the visitors browser - A JavaScript can be used to detect the visitors browser, and - depending on the browser - load another page specifically designed for that browserJavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitors computerHow to effectuate a JavaScript Into an HTML PageWhere to Put the JavaScriptJavaScripts in a page will be executed immediately while the page heaps into the browser. This is not always what we fate. Sometimes we want to execute a script when a page loads, other times when a user triggers an event.Scripts in the head divide Scripts to be executed when they are called, or when an event is triggered, go in the head section. When you place a scrip t in the head section, you will ensure that the script is loaded before anyone uses it.Scripts in the body section Scripts to be executed when the page loads go in the body section. When you place a script in the body section it generates the content of the page.Scripts in both the body and the head section You can place an unlimited number of scripts in your document, so you can have scripts in both the body and the head section.Using an impertinent JavaScriptSometimes you might want to run the same JavaScript on several(prenominal) pages, without having to write the same script on every page.To simplify this, you can write a JavaScript in an external file. Save the external JavaScript file with a .js file extension.Note The external script cannot contain the tagTo use the external script, point to the .js file in the src attribute of the tagJavaScript is Case SensitiveUnlike HTML, JavaScript is case sensitive - therefore celebrate your capitalization closely when you write Jav aScript statements, create or call variables, objects and functions.JavaScript StatementsA JavaScript statement is a command to the browser. The purpose of the command is to tell the browser what to do.This JavaScript statement tells the browser to write Hello Dolly to the web pageIt is normal to add a semicolon at the end of each viable statement. Most people think this is a good programming practice, and most often you will see this in JavaScript examples on the web.The semicolon is optional (according to the JavaScript standard), and the browser is supposed to interpret the end of the line as the end of the statement. Because of this you will often see examples without the semicolon at the end.Note Using semicolons makes it possible to write multiple statements on one line.JavaScript CodeJavaScript code (or just JavaScript) is a sequence of JavaScript statements.Each statement is executed by the browser in the sequence they are written.This example will write a header and two pa ragraphs to a web pageJavaScript BlocksJavaScript statements can be sort out together in close downs.Blocks start with a left curly bracket , and ends with a right curly bracket .The purpose of a block is to make the sequence of statements execute together.This example will write a header and two paragraphs to a web pageJavaScript comments can be used to make the code more readable.JavaScript CommentsComments can be added to explain the JavaScript, or to make it more readable.Single line comments start with //.This example uses single line comments to explain the codeUsing Comments to Prevent exploitIn this example the comment is used to stay the effect of a single code lineIn this example the comments is used to prevent the execution of multiple code linesUsing Comments at the End of a LineIn this example the comment is placed at the end of a lineVariables are containers for storing information.Declaring (Creating) JavaScript VariablesCreating variables in JavaScript is most often referred to as declaring variables.You can declare JavaScript variables with the var statementAfter the declaration shown above, the variables are empty (they have no prises as yet).However, you can also deal out values to the variables when you declare themAfter the execution of the statements above, the variable x will hold the value 5, and carname will hold the value Volvo.Note When you determine a text value to a variable, use quotes around the value. appoint Values to Undeclared JavaScript VariablesIf you assign values to variables that have not yet been declared, the variables will automatically be declared.These statementshave the same effect asRedeclaring JavaScript VariablesIf you redeclare a JavaScript variable, it will not lose its original value.After the execution of the statements above, the variable x will still have the value of 5. The value of x is not reset (or cleared) when you redeclare it.Conditional StatementsVery often when you write code, you want t o perform different actions for different decisions. You can use qualified statements in your code to do this.In JavaScript we have the following qualified statementsif statement - use this statement if you want to execute some code only if a specified condition is realif...else statement - use this statement if you want to execute some code if the condition is true and another code if the condition is falseif...else if....else statement - use this statement if you want to select one of many blocks of code to be executed alter statement - use this statement if you want to select one of many blocks of code to be executedscript type=text/javascript//If the time is less than 10,//you will get a replete(p) aurora greeting.//Otherwise you will get a Good twenty-four hours greeting.var d = new Date()var time = d.getHours()if (time document.write(Good morning)elsedocument.write(Good day)The JavaScript Switch StatementYou should use the switch statement if you want to select one of ma ny blocks of code to be executed.Syntax//You will receive a different greeting based//on what day it is. Note that Sunday=0,//Monday=1, Tuesday=2, etc.var d=new Date()theDay=d.getDay()switch (theDay)case 5document.write(Finally Friday)breakcase 6document.write( tops(predicate) Saturday)breakcase 0document.write(Sleepy Sunday)breakdefaultdocument.write(Im looking forward to this weekend)JavaScript Popup BoxesAlert BoxAn alert niche is often used if you want to make sure information comes by to the user.When an alert concussion pops up, the user will have to click OK to proceed.SyntaxConfirm BoxA confirm box is often used if you want the user to verify or accept something.When a confirm box pops up, the user will have to click either OK or Cancel to proceed.If the user clicks OK, the box returns true. If the user clicks Cancel, the box returns false.SyntaxPrompt BoxA restless box is often used if you want the user to input a value before entering a page.When a prompt box pops up, the user will have to click either OK or Cancel to proceed after entering an input value.If the user clicks OK the box returns the input value. If the user clicks Cancel the box returns null.SyntaxJavaScript unravelsJavaScript FunctionsTo persist in the browser from executing a script when the page loads, you can put your script into a function.A function contains code that will be executed by an event or by a call to that function.You may call a function from anywhere within the page (or even from other pages if the function is embedded in an external .js file).Functions can be defined both in the and in the section of a document. However, to assure that the function is read/loaded by the browser before it is called, it could be wise to put it in the section.How to Define a FunctionThe syntax for creating a function is
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.