SlideShare a Scribd company logo
1 of 15
Html5 <html5> <figure>Communications</figure> <a href='mailto:leonguo@sohu-inc.com'>leonguo</a> <time>2010.10</time> </html5>
HTML5 Communication HTML5 定义了两个增强型的文档通信模型 Cross Document Messaging XMLHttpRequest Level2
Widely-Used Models of CrossDomain  jsonp(JSON with Padding) + <script> document.domain + iframe flash + crossdomain.xml server proxy window.name + iframe window.location.hash + polling etc..
Cross Document Messaging cross-origin communication 定义了在 iframes/tabs/window 之间安全的跨源通信方案(using origin security) 定义统一的消息发送 API: PostMessage 提供了 JavaScript 上下文之间的异步消息传递机制
Origin Concept 同源:同协议,同域名和同端口 同源策略是客户端脚本(尤其是Javascript)的重要的安全度量标准。 它认为自任何站点装载的信赖内容是不安全的,只被允许访问来自同一站点的资源,而不是那些来自其它站点可能怀有恶意的资源。
PostMessage Architecture
Browser Support for PostMessage http://www.findmebyip.com/litmus#target-selector
A Original Demo
XMLHttpRequest Level 2 XmlHttpRequest Level 2 (XHR2)做了诸多改进: cross-origin requests progress events the handling of byte streams for both sending and receiving... XMLHttpRequest Level2 allows for cross-origin XMLHttpRequest using Cross Origin Resource Sharing(CORS)
Cross Origin Resource Sharing 简单来说,就是跨域的目标服务器要返回一系列的Headers,通过这些Headers来控制是否同意跨域。 4 Syntax HTTP Response Header  4.1 Access-Control-Allow-Origin 4.2 Access-Control-Max-Age 4.3 Access-Control-Allow-Credentials 4.4 Access-Control-Allow-Methods 4.5 Access-Control-Allow-Headers HTTP Request Header 4.6 Origin HTTP Request Header 4.7 Access-Control-Request-Method 4.8 Access-Control-Request-Headers
API  client var xhr2 = window.XDomainRequest ? new XDomainRequest : new XMLHttpRequest; xhr2.onload = function(){console.log(xhr2.responseText);} xhr2.open(“GET”,’server..'); xhr2.send(); Crossdomain.php <?php header('Access-Control-Allow-Origin: *'); echo 'hello world.';
Browser Support for XHR2 Chrome 2.0+ Firefox 3.5+ Safari 4.0+ IE 8.0+ // XDomainRequest
A Original Demo
Q&A
THANKS

More Related Content

Viewers also liked

Regional Newsletter (Winter 2014/15)
Regional Newsletter (Winter 2014/15)Regional Newsletter (Winter 2014/15)
Regional Newsletter (Winter 2014/15)ENPI FLEG
 
New Forests for New People
New Forests for New PeopleNew Forests for New People
New Forests for New PeopleSIANI
 
KW Outfront Magazine Online March/April 2009
KW Outfront Magazine Online  March/April 2009KW Outfront Magazine Online  March/April 2009
KW Outfront Magazine Online March/April 2009Keller Williams Careers
 
Adventures with Open Data in a Government World
Adventures with Open Data in a Government WorldAdventures with Open Data in a Government World
Adventures with Open Data in a Government WorldOpen Data @ CTIC
 
WITU Women and Girls
WITU Women and GirlsWITU Women and Girls
WITU Women and GirlsWeb Gathering
 
Deloitte Telecom Predictions 2010
Deloitte Telecom Predictions 2010Deloitte Telecom Predictions 2010
Deloitte Telecom Predictions 2010Plínio Okamoto
 
Convergence india 2012
Convergence india 2012Convergence india 2012
Convergence india 2012sp_cool
 
Streams API (Web Engines Hackfest 2015)
Streams API (Web Engines Hackfest 2015)Streams API (Web Engines Hackfest 2015)
Streams API (Web Engines Hackfest 2015)Igalia
 
OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...
OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...
OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...OpenAIRE
 
HTTP od zera do bohatera
HTTP od zera do bohateraHTTP od zera do bohatera
HTTP od zera do bohateraHordeTechnology
 
Estadiamento do Cancer de pulmão
Estadiamento do Cancer de pulmãoEstadiamento do Cancer de pulmão
Estadiamento do Cancer de pulmãoFlávia Salame
 
User Experience Mentoring (Ideabox Indonesia)
User Experience Mentoring (Ideabox Indonesia)User Experience Mentoring (Ideabox Indonesia)
User Experience Mentoring (Ideabox Indonesia)Dian Soraya
 

Viewers also liked (18)

Regional Newsletter (Winter 2014/15)
Regional Newsletter (Winter 2014/15)Regional Newsletter (Winter 2014/15)
Regional Newsletter (Winter 2014/15)
 
Oipf
OipfOipf
Oipf
 
New Forests for New People
New Forests for New PeopleNew Forests for New People
New Forests for New People
 
KW Outfront Magazine Online March/April 2009
KW Outfront Magazine Online  March/April 2009KW Outfront Magazine Online  March/April 2009
KW Outfront Magazine Online March/April 2009
 
Adventures with Open Data in a Government World
Adventures with Open Data in a Government WorldAdventures with Open Data in a Government World
Adventures with Open Data in a Government World
 
WITU Women and Girls
WITU Women and GirlsWITU Women and Girls
WITU Women and Girls
 
ACCESS Winter Magazine
ACCESS Winter MagazineACCESS Winter Magazine
ACCESS Winter Magazine
 
Deloitte Telecom Predictions 2010
Deloitte Telecom Predictions 2010Deloitte Telecom Predictions 2010
Deloitte Telecom Predictions 2010
 
Convergence india 2012
Convergence india 2012Convergence india 2012
Convergence india 2012
 
Streams API (Web Engines Hackfest 2015)
Streams API (Web Engines Hackfest 2015)Streams API (Web Engines Hackfest 2015)
Streams API (Web Engines Hackfest 2015)
 
Introduction to drupal
Introduction to drupalIntroduction to drupal
Introduction to drupal
 
OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...
OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...
OpenAIRE at the EC Consultation Workshop "Skills and Human Resources for e-In...
 
MakkelijkLezenPlein deel 2 Theek 5
MakkelijkLezenPlein deel 2 Theek 5MakkelijkLezenPlein deel 2 Theek 5
MakkelijkLezenPlein deel 2 Theek 5
 
The RuNet generation
The RuNet generationThe RuNet generation
The RuNet generation
 
9. Il Web semantico
9. Il Web semantico9. Il Web semantico
9. Il Web semantico
 
HTTP od zera do bohatera
HTTP od zera do bohateraHTTP od zera do bohatera
HTTP od zera do bohatera
 
Estadiamento do Cancer de pulmão
Estadiamento do Cancer de pulmãoEstadiamento do Cancer de pulmão
Estadiamento do Cancer de pulmão
 
User Experience Mentoring (Ideabox Indonesia)
User Experience Mentoring (Ideabox Indonesia)User Experience Mentoring (Ideabox Indonesia)
User Experience Mentoring (Ideabox Indonesia)
 

Similar to Hello communications(cn)

Re Introduce Web Development
Re Introduce Web DevelopmentRe Introduce Web Development
Re Introduce Web Developmentfinian lau
 
Flex 4.5 action data communication
Flex 4.5 action data communicationFlex 4.5 action data communication
Flex 4.5 action data communicationjexchan
 
Web开发基础
Web开发基础Web开发基础
Web开发基础dynaturtle
 
给聚划算后端开发的前端培训
给聚划算后端开发的前端培训给聚划算后端开发的前端培训
给聚划算后端开发的前端培训j5726
 
HTML & JavaScript
HTML & JavaScriptHTML & JavaScript
HTML & JavaScriptSanji Zhang
 
那些年,我们一起跨过域
那些年,我们一起跨过域那些年,我们一起跨过域
那些年,我们一起跨过域ksky521
 
Web开发与运维安全浅见
Web开发与运维安全浅见Web开发与运维安全浅见
Web开发与运维安全浅见CFC4N CHEN
 
Web开发与运维安全浅见
Web开发与运维安全浅见Web开发与运维安全浅见
Web开发与运维安全浅见mysqlops
 
Regular expression
Regular expressionRegular expression
Regular expressioncri fan
 
Flex 3 Cookbook 中文版V1
Flex 3 Cookbook 中文版V1Flex 3 Cookbook 中文版V1
Flex 3 Cookbook 中文版V1yiditushe
 
Peggy 重新認識java script
Peggy 重新認識java scriptPeggy 重新認識java script
Peggy 重新認識java scriptLearningTech
 
前端跨域总结
前端跨域总结前端跨域总结
前端跨域总结zhangsuoyong
 
Go语言: 互联网时代的C
Go语言: 互联网时代的CGo语言: 互联网时代的C
Go语言: 互联网时代的CGoogol Lee
 
Html5form
Html5formHtml5form
Html5formjay li
 
用 Go 語言打造 DevOps Bot
用 Go 語言打造 DevOps Bot用 Go 語言打造 DevOps Bot
用 Go 語言打造 DevOps BotBo-Yi Wu
 
Web Service&Soa&Esb入门介绍
Web Service&Soa&Esb入门介绍Web Service&Soa&Esb入门介绍
Web Service&Soa&Esb入门介绍yiditushe
 
非常靠谱 Html 5
非常靠谱 Html 5 非常靠谱 Html 5
非常靠谱 Html 5 Tony Deng
 
網頁設計
網頁設計網頁設計
網頁設計star9226
 

Similar to Hello communications(cn) (20)

Re Introduce Web Development
Re Introduce Web DevelopmentRe Introduce Web Development
Re Introduce Web Development
 
Flex 4.5 action data communication
Flex 4.5 action data communicationFlex 4.5 action data communication
Flex 4.5 action data communication
 
Web开发基础
Web开发基础Web开发基础
Web开发基础
 
给聚划算后端开发的前端培训
给聚划算后端开发的前端培训给聚划算后端开发的前端培训
给聚划算后端开发的前端培训
 
HTML & JavaScript
HTML & JavaScriptHTML & JavaScript
HTML & JavaScript
 
那些年,我们一起跨过域
那些年,我们一起跨过域那些年,我们一起跨过域
那些年,我们一起跨过域
 
Web开发与运维安全浅见
Web开发与运维安全浅见Web开发与运维安全浅见
Web开发与运维安全浅见
 
Web开发与运维安全浅见
Web开发与运维安全浅见Web开发与运维安全浅见
Web开发与运维安全浅见
 
Hadoop ecosystem
Hadoop ecosystemHadoop ecosystem
Hadoop ecosystem
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Flex 3 Cookbook 中文版V1
Flex 3 Cookbook 中文版V1Flex 3 Cookbook 中文版V1
Flex 3 Cookbook 中文版V1
 
Peggy 重新認識java script
Peggy 重新認識java scriptPeggy 重新認識java script
Peggy 重新認識java script
 
前端跨域总结
前端跨域总结前端跨域总结
前端跨域总结
 
Go语言: 互联网时代的C
Go语言: 互联网时代的CGo语言: 互联网时代的C
Go语言: 互联网时代的C
 
Html5form
Html5formHtml5form
Html5form
 
用 Go 語言打造 DevOps Bot
用 Go 語言打造 DevOps Bot用 Go 語言打造 DevOps Bot
用 Go 語言打造 DevOps Bot
 
Web Service&Soa&Esb入门介绍
Web Service&Soa&Esb入门介绍Web Service&Soa&Esb入门介绍
Web Service&Soa&Esb入门介绍
 
Html培训
Html培训Html培训
Html培训
 
非常靠谱 Html 5
非常靠谱 Html 5 非常靠谱 Html 5
非常靠谱 Html 5
 
網頁設計
網頁設計網頁設計
網頁設計
 

Hello communications(cn)

  • 1. Html5 <html5> <figure>Communications</figure> <a href='mailto:leonguo@sohu-inc.com'>leonguo</a> <time>2010.10</time> </html5>
  • 2. HTML5 Communication HTML5 定义了两个增强型的文档通信模型 Cross Document Messaging XMLHttpRequest Level2
  • 3. Widely-Used Models of CrossDomain jsonp(JSON with Padding) + <script> document.domain + iframe flash + crossdomain.xml server proxy window.name + iframe window.location.hash + polling etc..
  • 4. Cross Document Messaging cross-origin communication 定义了在 iframes/tabs/window 之间安全的跨源通信方案(using origin security) 定义统一的消息发送 API: PostMessage 提供了 JavaScript 上下文之间的异步消息传递机制
  • 5. Origin Concept 同源:同协议,同域名和同端口 同源策略是客户端脚本(尤其是Javascript)的重要的安全度量标准。 它认为自任何站点装载的信赖内容是不安全的,只被允许访问来自同一站点的资源,而不是那些来自其它站点可能怀有恶意的资源。
  • 7. Browser Support for PostMessage http://www.findmebyip.com/litmus#target-selector
  • 9. XMLHttpRequest Level 2 XmlHttpRequest Level 2 (XHR2)做了诸多改进: cross-origin requests progress events the handling of byte streams for both sending and receiving... XMLHttpRequest Level2 allows for cross-origin XMLHttpRequest using Cross Origin Resource Sharing(CORS)
  • 10. Cross Origin Resource Sharing 简单来说,就是跨域的目标服务器要返回一系列的Headers,通过这些Headers来控制是否同意跨域。 4 Syntax HTTP Response Header 4.1 Access-Control-Allow-Origin 4.2 Access-Control-Max-Age 4.3 Access-Control-Allow-Credentials 4.4 Access-Control-Allow-Methods 4.5 Access-Control-Allow-Headers HTTP Request Header 4.6 Origin HTTP Request Header 4.7 Access-Control-Request-Method 4.8 Access-Control-Request-Headers
  • 11. API client var xhr2 = window.XDomainRequest ? new XDomainRequest : new XMLHttpRequest; xhr2.onload = function(){console.log(xhr2.responseText);} xhr2.open(“GET”,’server..'); xhr2.send(); Crossdomain.php <?php header('Access-Control-Allow-Origin: *'); echo 'hello world.';
  • 12. Browser Support for XHR2 Chrome 2.0+ Firefox 3.5+ Safari 4.0+ IE 8.0+ // XDomainRequest
  • 14. Q&A

Editor's Notes

  1. http://newclub.sohu.com/test/leon/h5_message/
  2. http://newclub.sohu.com/test/leon/crossdomain.php