Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript
JavaScript
  1. HTML5 applicationCache vs Browser Cache

    HTML5 applicationCache เข้าใจได้จากตัวอย่าง web application ถูก cache เข้าถึงได้โดยไม่ต้องมี internet connection Application cache ข้อดี: ผู้ใช้ใช้แอปออฟไลน์ได้ cached resources โหลดเร็วกว่า ลด server load Browser cache Web browsers ใช้ caching เก็บ HTML web pages โดยเก็บ copy ของ visited pages ใช้

  2. Frame-by-frame animation ใน HTML5 ด้วย canvas

    เพื่อสร้าง frame-by-frame animation ใน HTML5 ด้วย canvas ลองรันโค้ด: lastImage) { clearInterval(timer); } else { img.src = images/left_hnd_ + (myImageNum++) + .png; } }, 1000 / 15);

  3. ปรับเว็บเพจเดิมให้รองรับ mobile ด้วย CSS

    เพื่อ retrofit ใช้ CSS media queries อนุญาต stylesheets ต่างๆ สำหรับความสามารถเบราว์เซอร์ต่างกัน ข้อดีคือไม่ต้องเขียน server-side code ต้องเพิ่ม detection code ใน script สำหรับจัดกลุ่มอุปกรณ์ Media queries จัดการอุปกรณ์ที่คุณไม่เคยรู้จัก ตั้งค่าดังนี้: @media handheld and (max-width: 480px), screen

  4. ได้ GPS precision สูงสุดบน mobile browser

    Built-in browser สำหรับ Android จะไม่ให้ accurate GPS location เพื่อเหตุผลด้านความปลอดภัย ทดสอบกับเบราว์เซอร์ต่างๆ ที่ขอ permission เพื่อได้ accurate location จาก GPS เมื่อติดตั้ง หลังปิด GPS ข้อมูลได้รับด้วยความแม่นยำ < 10 เมตร อย่าใช้ Android Browser สำหรับเว็บไซต์ หากต้องการ GPS location ความแม่น

  5. เล่นวิดีโอบน canvas และเก็บเฟรมสุดท้าย/ภาพไว้บน HTML5 Canvas

    ลองรันโค้ดด้านล่างเพื่อเล่นและเก็บเฟรมสุดท้ายของวิดีโอ: var c = $(canvas)[0]; var context = canvas.getContext(2d); c.width = 640; c.height = 480; $(#myPlayer).on(play, function (e) { var $this = this; (function loop() { if (!$this.paused && !$this.ended) { context.drawImage($th

  6. เขียนฟอร์มช่วย browser auto-complete feature อย่างไร?

    สเปก HTML5 อย่างเป็นทางการระบุ: เมื่อ autofill field name เป็น on user agent ควรพยายามใช้ heuristics กำหนดค่าที่เหมาะสมเสนอผู้ใช้ เช่นจาก name value, ตำแหน่งใน DOM... ใช้ค่าเหล่านี้สำหรับ autocomplete attribute: Field NameMeaning nameFull name honoritic-prefixPrefix/title (Mr., Ms., Dr., M||e) g

  7. สร้าง Full Page Drag and Drop สำหรับอัปโหลดไฟล์ด้วย HTML5 JavaScript

    บทนำ Drag and Drop API ของ HTML5 ช่วยให้สร้างพื้นที่วางไฟล์ (Drop Zone) ขนาดเต็มหน้าจอได้ โดยใช้ event ต่างๆ ของ Drag and Drop API โค้ดตัวอย่าง // HTML <div id=dropZone style=display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); z-index:9999; text-alig

  8. toDataURL โยน Uncaught Security exception ใน HTML

    เพื่อแก้ Uncaught Security Exception ให้เพิ่มแอตทริบิวต์ crossorigin: <img id=myid crossorigin=anonymous src=https://www.tutorialspoint.com/images/seaborn-4.jpg?v=2> function getBase64() { var myImg = document.getElementById(myid); var c = document.createElement(canvas); c.width = myImg.

  9. ตรวจจับรูปแบบวันที่ของเบราว์เซอร์สำหรับ HTML input type date

    เมธอด input.valueAsDate คืนค่า Date object สะท้อนค่าปัจจุบันของ input รูปแบบที่แสดงจะเหมือนกัน ทำให้ทำงานได้: new Date().toISOString().substr(0, 10); new Date().toLocaleDateString(); input.valueAsDate; input.valueAsDate.toLocaleDateString(); new Date(input.valueAsDate); new Date(input.valueAsDate).t

  10. HTML5 audio ไม่เล่นใน PhoneGap App

    หากตั้งค่า attributes และ audio source ถูกต้องแล้ว อาจเป็น security issue เพิ่มใน index.html: <meta http-equiv=Content-Security-Policy content=default-src self https://appvipswi.easwi.it; script-src self unsafe-inline; media-src self> ตั้ง AndroidManifest.xml: <uses-permission android:name=

  11. Fire HTML5 dragstart หลัง mousemove แบบ programmatic

    เพื่อ fire dragstart หลัง mousemove ลองดังนี้: หากคุณ fire dragstart event ให้ implement process flow ที่เหลือด้วย เพื่อแก้ปัญหา สร้าง user experience ดังนี้: แจ้งให้ผู้ใช้คลิกที่พื้นที่สำหรับ enable drag เมื่อคลิก แสดง dialog ว่าสามารถ drag ได้แล้ว

  12. Filter รูปภาพ grayscale, ขาวรอบ PNG ใน Internet Explorer 8

    Filters ที่จะ apply ต้องรวมใน single filter call ตั้งค่าดังนี้: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1) CSS ควรทำงานแบบนี้: .demo { background: transparent; -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF) progid:DXImageTrans

  13. ทำให้ HTML5 input type="number" รับ dash ได้

    เพื่อให้ HTML5 input type=number รับ dash ให้ใช้ regular expression เพิ่ม regex ใน attribute pattern: [0-9]+([-\,][0-9]+)? เพิ่มในโค้ด: <input type=text pattern=[0-9]+([-\,][0-9]+)? name=my-num title=dashes or comma /> วิธีนี้อนุญาต dash ในตัวเลข แต่ต้องใช้ input type text แทน number

  14. ใช้ client-side XSLT transformations ใน HTML5

    Client-side XSLTProcessor API เป็นส่วนหนึ่งของ HTML5 scripting specification: เมื่อ XSLT transformation program ถูก trigger โดย processing instruction และ browser implement direct-to-DOM transformation script elements ที่สร้างโดย XSLT processor ต้องถูก marked parser-inserted และ run in document orde

  15. HTML5 validity ของ nested tables

    Validator ถือตารางต่อไปนี้ว่า valid: <!DOCTYPE html> <html> <head> <meta charset=utf-8> <title>Example</title> </head> <body> <table> <tbody> <tr> <td> <table>

  16. HTML5 audio control stop button

    ลองโค้ดด้านล่างเพื่อเพิ่มปุ่ม stop ให้ audio ใน HTML5: function displayStopBtn() { var myPlayer = document.getElementsByTagName(audio)[0]; myPlayer.pause(); myPlayer.currentTime = 0; } รวม jQuery ได้ด้วย: $(#stopButton).click(function () { audio.pause(); audio.currentTime = 0; });

  17. Cross origin HTML <video> โหลดไม่ได้ใน Google Chrome

    เพื่อแก้ปัญหาโหลด <video> element ต้องตั้ง cross-origin เป็น anonymous: <video crossorigin=anonymous></video> อีกวิธี อาจเกิดจากขาด response header Access-Control-Allow-Headers ที่มี HTTP headers ตรงกับ Access-Control-Request-Headers request header

Total 5941 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:209/298  20-คอมพิวเตอร์/Page Goto:1 203 204 205 206 207 208 209 210 211 212 213 214 215