SlideShare une entreprise Scribd logo
1  sur  12
Télécharger pour lire hors ligne
The HTML5 Solution to Ajax Pitfalls on Mobile Devices.
         AT&T Mobile App Hackathon - Atlanta
         Speaker: Wesley Hales
         @wesleyhales

Saturday, September 10, 2011
Wesley Hales
                               • Senior Developer at Red Hat           @w
                                                                         esle
                               • W3C Member                                  yha
                                                                                les
                               • HTML5 User Group Founder
                               • html5rocks.com, DZone Refcard, and author of
                                 many other articles around the web.




Saturday, September 10, 2011
Saturday, September 10, 2011
innerHTML()




Saturday, September 10, 2011
“If the HTML text contains a <script> tag or its
                               equivalent, then an evil script will run. ..

                                                    Douglas Crockford - Javascript The Good Parts




Saturday, September 10, 2011
Java only is innerHTML() bad...
                                Not Mobile Web Settings

                               • Causes browser memory leaks
                               • You don’t get a reference to the element
                                 you just created

                               • Problems with some elements setting
                                 their innerHTML

                               • And it fails on iOS...




Saturday, September 10, 2011
Java Mobile Web Settings
                               Beware of innerHTML on


                               • Stops working randomly
                               • It’s a 4 year old problem in Safari
                               • there are hacks to workaround
                                 • setTimeout(‘yuck’)




Saturday, September 10, 2011
Java Mobile Web Settings
                                     The   Solution

                                • get the xhr.responseText
                                • send it to an automatically generated
                                  HTML5 sandbox iframe

                                • pull from the iframe DOM and use
                                  document.adoptNode




Saturday, September 10, 2011
Java Mobile Web Settings
                                     The   Solution
                               function getFrame() {
                                   var frame = document.getElementById("temp-frame");
                                   if (!frame) {
                                       // create frame
                                       frame = document.createElement("iframe");
                                       frame.setAttribute("id", "temp-frame");
                                       frame.setAttribute("name", "temp-frame");
                                       frame.setAttribute("seamless", "");
                                       frame.setAttribute("sandbox", "");
                                       frame.style.display = 'none';
                                       document.documentElement.appendChild(frame);
                                   }
                                   return frame.contentDocument;
                               }




Saturday, September 10, 2011
Java Mobile Web Settings
                                     The   Solution


                                var frame = getFrame();
                                frame.write(responseText);




Saturday, September 10, 2011
Java Mobile Web Settings
                                       The   Solution
                               document.
                               getElementById(elementId).
                               appendChild(document.adoptNode
                               (incomingElements));




Saturday, September 10, 2011
Mobile Web Apps Live (or DIE) by the UI
                                           Questions?




Saturday, September 10, 2011

Contenu connexe

Plus de Wesley Hales (6)

JavaOne 2011 - Going Mobile With Java Based Technologies Today
JavaOne 2011 - Going Mobile With Java Based Technologies TodayJavaOne 2011 - Going Mobile With Java Based Technologies Today
JavaOne 2011 - Going Mobile With Java Based Technologies Today
 
Making Portals Cool: The Compelling Advantages of a Portlet Bridge
Making Portals Cool: The Compelling Advantages of a Portlet BridgeMaking Portals Cool: The Compelling Advantages of a Portlet Bridge
Making Portals Cool: The Compelling Advantages of a Portlet Bridge
 
If You Know JSF, You Know Portals and Portlets
If You Know JSF, You Know Portals and PortletsIf You Know JSF, You Know Portals and Portlets
If You Know JSF, You Know Portals and Portlets
 
GateIn - The Solution for Managing and Building Enterprise Web Apps
GateIn - The Solution for Managing and Building Enterprise Web AppsGateIn - The Solution for Managing and Building Enterprise Web Apps
GateIn - The Solution for Managing and Building Enterprise Web Apps
 
GateIn - Presented at Atlanta JUG on 1/19/2010
GateIn - Presented at Atlanta JUG on 1/19/2010GateIn - Presented at Atlanta JUG on 1/19/2010
GateIn - Presented at Atlanta JUG on 1/19/2010
 
Ajax In Enterprise Portals
Ajax In Enterprise PortalsAjax In Enterprise Portals
Ajax In Enterprise Portals
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

The HTML5 Solution to Ajax Pitfalls on Mobile Devices

  • 1. The HTML5 Solution to Ajax Pitfalls on Mobile Devices. AT&T Mobile App Hackathon - Atlanta Speaker: Wesley Hales @wesleyhales Saturday, September 10, 2011
  • 2. Wesley Hales • Senior Developer at Red Hat @w esle • W3C Member yha les • HTML5 User Group Founder • html5rocks.com, DZone Refcard, and author of many other articles around the web. Saturday, September 10, 2011
  • 5. “If the HTML text contains a <script> tag or its equivalent, then an evil script will run. .. Douglas Crockford - Javascript The Good Parts Saturday, September 10, 2011
  • 6. Java only is innerHTML() bad... Not Mobile Web Settings • Causes browser memory leaks • You don’t get a reference to the element you just created • Problems with some elements setting their innerHTML • And it fails on iOS... Saturday, September 10, 2011
  • 7. Java Mobile Web Settings Beware of innerHTML on • Stops working randomly • It’s a 4 year old problem in Safari • there are hacks to workaround • setTimeout(‘yuck’) Saturday, September 10, 2011
  • 8. Java Mobile Web Settings The Solution • get the xhr.responseText • send it to an automatically generated HTML5 sandbox iframe • pull from the iframe DOM and use document.adoptNode Saturday, September 10, 2011
  • 9. Java Mobile Web Settings The Solution function getFrame() {     var frame = document.getElementById("temp-frame");     if (!frame) {         // create frame         frame = document.createElement("iframe");         frame.setAttribute("id", "temp-frame");         frame.setAttribute("name", "temp-frame");         frame.setAttribute("seamless", "");         frame.setAttribute("sandbox", "");         frame.style.display = 'none';         document.documentElement.appendChild(frame);     }     return frame.contentDocument; } Saturday, September 10, 2011
  • 10. Java Mobile Web Settings The Solution var frame = getFrame(); frame.write(responseText); Saturday, September 10, 2011
  • 11. Java Mobile Web Settings The Solution document. getElementById(elementId). appendChild(document.adoptNode (incomingElements)); Saturday, September 10, 2011
  • 12. Mobile Web Apps Live (or DIE) by the UI Questions? Saturday, September 10, 2011