HTML5 Programming With Javascript For DummiesHTML5Programmingwith JavaScriptDUMMIESFORA Wiley Brandby John Paul muellerFORDUMMLESA wiley Brandooks com/HTML5 Programming with JavaScript For dummiesPublished byJohn Wiley sons, Inc.111 River streetHoboken. NJ07030-5774www.wiley.comCopyright o 2013 by John Wiley sons, Inc, Hoboken, New JerseyPublished simultaneously in CanadaNo part of this publication may be reproduced, stored in a retrieval system or transmitted in any form orted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written itby any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permit-permission of the Publisher, or authorization through payment of the appropriate per-copy fee to theCopyright Clearance Center, 222 Rosewood Drive, Danvers, MA01923, (978)750-8400, fax(978)646-8600Sons, Inc, 111 River Street, Hoboken, NJ07030, (201)748-6011, fax(201)748-6008, or online at ntprsRequests to the Publisher for permission should be addressed to the Permissions Department, John wileywww.wiley.com/go/permissionsTrademarks: Wiley, the wiley logo, For Dummies, the Dummies Man logo, A Reference for the rest of Us!TheDummiesWay,DummiesDailyTheFunandEasyWay,Dummies.com,MakingevErythingEasier,andowners. John Wiley &Sons, InC is not associated with any product or vendor mentioned in this boo aurelated trade dress are trademarks or registered trademarks of John Wiley sons, Inc and or its affiliatesin the United States and other countries, and may not be used without written permission. JavaScript isa registered trademark of Oracle America, Inc. All other trademarks are the property of their respectiLIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NOREPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESSOF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES. INCLUDINGWITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTYMAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE ANDSTRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK ISSOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGALACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIREDTHE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THEPUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACTTHAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/ORA POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THEPUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE ORRECOMMENDATIONS IT MAY MAKE FURTHER. READERS SHOULD BE AWARE THAT INTERNETWEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THISWORK WAS WRITTEN AND WHEN IT IS READFor general information on our other products and services, please contact our Customer CareDepartment within the U.s. at 877-762-2974, outside the U.s. at 317-572-3993, or fax 317-572-4002Fortechnicalsupportpleasevisitwww.wileycom/techsupport.Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some materialincluded with standard print versions of this book may not be included in e-books or in print-on-demandIf this book refers to media such as a cd or dvd that is not included in the version you purchased youmaydownloadthismaterialathttp://booksupport.wileycomFormoreinformationaboutWileyproductsvisitwww.wiley.comLibrary of congress control Number: 2013936244ISBN9781-118-431665(pbk);ISBN978-1-118-46209-6(ebk);ISBN9781-118-611883(ebk);sBN978-1-118-494189(ebk)Manufactured in the united states of america10987654321ooks com/About the AuthorJohn mueller is a freelance author and technical editor. He has writing in hisblood, having produced 91 books and over 300 articles to date. The topicsrange from networking to artificial intelligence and from database man-agement to heads-down programming Some of his current books includeWindows command-line references books on vba and visio. several bookson C#, and an IronPython programmer's guide His technical editing skillshave helped more than 63 authors refine the content of their manuscriptsJohn has provided technical editing services to both Data Based Advisorand coast Compute magazines. He's also contributed articles to magazineslike such as Software Quality Connection, DevSource, InformIT, SQL ServerProfessional, Visual C++ Developer, Hard Core visual Basic, asp. netPRO,Software Test and Performance, and visual Basic Developer. Be sure to readJohnsblogathttp://blog.johnmuellerbooks.comWhen John isnt working at the computer, you can find him outside in thegarden, cutting wood, or generally enjoying nature. John also likes makingwine and knitting. When not occupied with anything else, he makes glycerinsoap and candles, which comes in handy for gift baskets. You can reach Johnon the Internet at JohnaJohnMuellerBooks com. John is also setting up awebsiteathttp://www.johnmuellerbooks.comFeelfreetotakealookand make suggestions on how he can improve itooks com/ooks com/DedicationDedicated to people who have given me hope and who have helped merealize new potential as an author; on the occasion of their 50th anniversary,Bill and Karen bridgesAuthor' s AcknowledgmentsThanks to my wife, Rebecca, for working with me to get this book completedI really dont know what I would have done without her help in researchingand compiling some of the information that appears in this book. She also dida fine job of proofreading my rough draft. Rebecca keeps the house runningwhile l,'m buried in workRuss mullen deserves thanks for his technical edit of this book. He greatlyadded to the accuracy and depth of the material you see here. russ is alwaysproviding me with great URLS for new products and ideas. However, it's thetesting Russ does that helps most. He's the sanity check for my work. russalso has different computer equipment than mine, so he's able to point outflaws that I might not otherwise noticeMatt Wagner, my agent, deserves credit for helping me get the contract inthe first place and taking care of all the details that most authors dont reallyconsider. I always appreciate his assistance. It's good to know that someonewants to helpA number of people read all or part of this book to help me refine theapproach, test the coding examples, and generally provide input that allreaders wish they could have. These unpaid volunteers helped in ways toonumerous to mention here. I especially appreciate the efforts of Eva beattie,Glenn russell, Osvaldo tellez almirall, and gerald wilson, Jr, who providedgeneral input, read the entire book, and selflessly devoted themselves to thisproject.Finally, I would like to thank Kim Darosett, Katie Feltman, Virginia SandersKatie Crocker, and the rest of the editorial and production staff at Wiley fortheir assistance in bringing this book to print. It's always nice to work withsuch a great group of professionalsooks com/Publishers AcknowledgmentsWereproudofthisbookpleasesendusyourcommentsathttp://dummies.custhelp.comFor other comments, please contact our Customer Care Department within the U.s. at 877-762-2974outside the u.s. at 317-572-3993 or fax 3 17-572-4002Some of the people who helped bring this book to market include the followingAcquisitions and EditorialComposition ServicesSenior Project Editor: Kim DarosettProject Coordinator: Katherine CrockerAcquisitions Editor: Constance SantistebanLayout and graphics: Amy AssosCopy editor: Virginia SandersJoyce haugheyTechnical editor russ mullenProofreaders: Jessica Kramer. Lisa stiersEditorial Manager: Leah michaelIndexer: Ty KoontzEditorial Assistant: Annie SullivanSenior editorial assistant: Cherie CaseCover Photo: O kertlis/iStockphotoPublishing and editorial for Technology dummiesRichard swadley, Vice President and Executive Group PublisherAndy Cummings, Vice President and PublisherMary bednarek, Executive Acquisitions DirectorMary c. corder, Editorial DirectorPublishing for Consumer DummiesKathleen Nebenhaus. Vice President and executive PublisherComposition ServicesDebbie Stailey, Director of Composition Servicesooks com/Table of contentsntroductionAbout this book…1What You dont have to readFoolish Assumptions2Conventions used in This bookHow This Book Is Organized..Part 1: Understanding the Basics of JavaScriptPart I Speaking the JavaScript LanguagePart Ill: Meeting JavaScripts Control Structures4Part IV: Interacting with Users and HTMLPart V: Extending JavaScript FurtherPart VI: The part of tensThe companion WebsiteIcons used in This bookWhere to go from here6Part 1: understanding the Basics of JavaScript.n. gChapter 1: HTML, Say Hello to JavaScriptIntroducing JavaScript12Java and Javascript arent long-lost relativesRecognizing the benefits of JavaScript……Seeing How JavaScript Fits into an HTML Document.16Starting an HTML5 document16Understanding the alert functionUsing the 卡了网 - Kaledl.Com