Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JavaScript crossdomain access
Branch: master
Pull request Compare This branch is even with colorhook:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
YQL
access-control
cross-frame
flash-localconnection
flash-urlloader
fragment-identitier-messaging
jsonp
server-proxy
window-domain
window-name
window-postMessage
README.textile

README.textile

How to share resources crossing domain

These code snippet are a case collection for sharing resources between different domains.

Server Proxy

Server Proxy is using web server to request data from other domain(s) and than provide to self domain,
JavaScript needn’t create a cross-domain HTTP request but just retrieve data from local host.

JSONP

JSONP (JSON with padding) is a easy method, using JavaScript annotation, to share data cross domain.
JavaScript can be load from another domain but has no restriction to execution.

Flash URLLoader

Flash has another security policy, it’s can load data from another domain by setting the policy flie crossdomain.xml.

Access Control

After setting specific HTTP response headers, the resource can to shared to other domains.

window.domain

domain and sub-domain can conmunicate each other after setting their window’s domain property to the same.

window.name

In a window frame, we can assign value to the name property and then change the location URL to the same domain
as parent window frame, then the parent can read the name property. this is a efficient method to share data cross domain.

window.postMessage

window.postMessage is a newer method, which has less browsers support at present, to share data between domains.

FIM – Fragment Identiter Message

the containing page sets the URL fragment identifier of an embedded IFrame, and the IFrame must poll to detect changes
in the value of its location.hash property. this technique allow two-way comunications.

Flash LocalConnection

We can using Flash LocalConnection API to communicate crossing domain, this API allow different SWF call each other, the SWF
can be embeded in HTML page, or play in a standlone player.

Cross Frame

Cross Frame is a variant of the URL fragment identifier mechanism, which add a blank iframe as a proxy, no extra history records occur
and needn’t polling the location hash chang. It however cannot work on Opera, so we need using an other way for Opera browser.
see http://www.julienlecomte.net/blog/2007/11/31/

YQL

YQL (Yahoo! Query Language) is an expressive SQL-like language that lets you query, filter, and join data across Web services.
Yahoo! and other websites across the Internet make much of their structured data available to developers, primarily through Web services. To access and query these services, developers traditionally endure the pain of locating the right URLs and documentation to access and query each Web service.
With YQL, developers can access and shape data across the Internet through one simple language, eliminating the need to learn how to call different APIs.
see http://developer.yahoo.com/yql/
YQL console http://developer.yahoo.com/yql/console/

Something went wrong with that request. Please try again.