easyxdm

22
easyXDM Maybe it is the best and easist cross- domain scripting in the world Wilson 2010-12- 19 1

Upload: willing8310

Post on 15-Jan-2015

2.790 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: easyXDM

easyXDMMaybe it is the best and easist cross-domain scripting

in the world

Wilson2010-12-19

1

Page 2: easyXDM

Scenarios

2

Page 3: easyXDM

Same Origin Policy

• var getReply = function (id) {• $.get(“http://disqus.com”, {• 'post_id': id• }, function (data) {• //….• }, 'json');• }

3

Page 4: easyXDM

Same Origin Policy

• var getReply = function (id) {• $.get(“http://disqus.com”, {• 'post_id': id• }, function (data) {• //….• }, 'json');• }

4

Page 5: easyXDM

Same Origin Policy

Prevent the loss of data confidentiality or integrity

5

Page 6: easyXDM

Yea,but what if …

I own both sites and I just want to make them talk?The site I want information from says it’s okay?I don’t give a shit?!

6

Page 7: easyXDM

The solution

Window.postMessage

Works in…•FF3+•IE8+•Chrome 1+•Safari 4+•Opera

7

Page 8: easyXDM

The solution

JSONP

8

Page 9: easyXDM

The solution

Server-Side Proxy

9

Page 10: easyXDM

The solution

• HTML5 Cross-Document Messaging• W3C XMLHttpRequest Level 2• IE8 XDomainRequest• iFrame hacks• …

10

Page 11: easyXDM

都是浮云!

11

Page 12: easyXDM

Men,we need a bit of flexibility

12

Page 13: easyXDM

easyXDMhttps://github.com/oyvindkinsey/easyXDM

13

Page 14: easyXDM

easyXDM

• use postMessage first and then a series of use postMessage first and then a series of different techniques based on which browser different techniques based on which browser

you use, but with normalized syntaxyou use, but with normalized syntax

14

Page 15: easyXDM

easyXDM

15

Page 16: easyXDM

Setting up your first Socket

• The provider

16

Page 17: easyXDM

Setting up your first Socket

• The consumer

17

Page 18: easyXDM

Cross-domain AJAX

• The provider

18

Page 19: easyXDM

Cross-domain AJAX

• The consumer

19

Page 20: easyXDM

So easy,right?

20

Page 21: easyXDM

21

Page 22: easyXDM

Thanks!

• Wilson Lin• @willing8310• [email protected]• http://36kr.com

Please feel free to contact me if any questions.

22