1. 项目地址:
https://github.com/krakenjs/xcomponent
2. 支持的特性
a. Render an iframe or popup on a different domain, and pass down props, including objects
and functions
b. Call callbacks natively from the child window without worrying about post-messaging or
cross-domain restrictions
c. Create and expose components to share functionality from your site to others!
3. 简单使用
// Define a component:
var MyLoginComponent = xcomponent.create({ tag: 'my-login-component',
url: 'http://www.my-site.com/my-login-component'
});
// Render the component on the parent page:
MyLoginComponent.render({ prefilledEmail: 'foo@bar.com', onLogin: function(email) {
console.log('User logged in with email:', email);
} }, '#container'); //Implement the component in the iframe: <input type="text" id="email" />
<input type="password" id="password" />
<button id="login">Log In</button> <script>
var email = document.querySelector('#email');
var password = document.querySelector('#password');
var button = document.querySelector('#login'); email.value = window.xprops.prefilledEmail; button.addEventListener('click', function() {
if (validUser(email.value, password.value)) {
window.xprops.onLogin(email.value);
}
});
</script>
4.  参考资料
https://github.com/krakenjs/xcomponent
https://github.com/krakenjs/xcomponent/blob/master/docs/api.md
 
 
 
 

xcomponent web 跨域组件介绍的更多相关文章

  1. web跨域访问,session丢失的问题

    web跨域访问,session丢失的问题25 http://www.iteye.com/problems/71265 http://www.iteye.com/topic/264079 具体情况如下: ...

  2. Web跨浏览器进程通信(Web跨域)

    Web跨域已是老生常谈的话题,这次来尝试下跨域浏览器进程之间的通信 —— 这在过去基本依靠网络中转实现   在之前一篇文章里尝试了跨浏览器的数据共享,最后提到使用LocalConnection还可以实 ...

  3. web跨域及cookie相关知识总结

    原文:web跨域及cookie相关知识总结   之前对于跨域相关的知识一致都很零碎,正好现在的代码中用到了跨域相关的,现在来对这些知识做一个汇总整理,方便自己查看,说不定也可能对你有所帮助. 本篇主要 ...

  4. web跨域问题回顾

    晚上看spring web源码时看到了cors包,查了一下原来是在4.2之后新加的用来更方便让web应用服务支持cors协议的.于是有了下面几个问题. web跨域问题的起源是因为浏览器为了安全而遵循的 ...

  5. java web 跨域

    服务器端解决跨域问题的三种方法   跨域是指html文件所在的服务器与ajax请求的服务器是不同的ip+port,例如: - ‘192.168.1.1:8080’ 与 ‘192.168.1.2:808 ...

  6. 浅谈WEB跨域的实现(前端向)

    同源策略/SOP(Same origin policy)是一种约定,它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,浏览器很容易受到XSS.CSFR等攻击(可以参考我的这篇文章). SOP要求 ...

  7. Web跨域问题总结

    一.跨域问题的由来为了防止某些文档或脚本加载别的域下的未知内容造成泄露隐私,破坏系统等安全行为,1995年, Netscape 公司在浏览器中引入同源策略/SOP(Same origin policy ...

  8. web跨域解决方案

    阅读目录 什么是跨域 常用的几种跨域处理方法: 跨域的原理解析及实现方法 总结 摘要:跨域问题,无论是面试还是平时的工作中,都会遇到,本文总结处理跨域问题的几种方法以及其原理,也让自己搞懂这方面的知识 ...

  9. WEB跨域的实现

    同源策略/SOP(Same origin policy)是一种约定,它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,浏览器很容易受到XSS.CSFR等攻击(可以参考我的这篇文章). SOP要求 ...

随机推荐

  1. 使用POI做的一个生成Excel的工具类。包含了导出Excel和解析Excel方法

    PoiExcelUtils.java /** * */ package com.common.office; import java.io.File; import java.io.FileInput ...

  2. Ubuntu gcc错误:对'log'等函数未定义的引用

    Ubuntu gcc错误:对'log'等函数未定义的引用 a.c #include <stdio.h>#include <math.h>int main(){    float ...

  3. Android Studio Gradle Could not reserve enough space for object heap

    Studio 创建第一个工程报错 Error:Unable to start the daemon process.This problem might be caused by incorrect ...

  4. [SCOI2005]扫雷Mine

    1088: [SCOI2005]扫雷Mine Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2028  Solved: 1187[Submit][St ...

  5. LINUX系统运行查看

    1.查看内存使用情况 free -m 2.查看内存,cpu等使用情况排序,使用ps -aux命令 ps -aux --sort=+rss :按内存升序排列 ps -aux --sort=-rss :按 ...

  6. 判断iframe页面是否是顶层页面

    if (self!=top) {  window.parent.location.reload();}

  7. MVC viewbag & viewdata

    弱类型:ViewData[""] 动态型:ViewBag dynamic ViewData 是字典型的(Dictionary),ViewBag 不再是字典的键值对结构,而是dyna ...

  8. scala mapPartitionsWithIndex函数的使用

    var rdd1=sc.makeRDD(Array((1,"A"),(2,"B"),(3,"C"),(4,"D")),2 ...

  9. oracle 结构化语言查询 DML DDL DCL

    --结构化查询语言 (Structured Query Language),具有定义. --查询.更新和控制等多种功能,是关系数据库的标准语言. --SQL分类: -- 数据操纵语言DML Data ...

  10. 智课雅思词汇---二十五、-ate

    智课雅思词汇---二十五.-ate 一.总结 一句话总结:又是动词,又是名词,又是形容词 后缀:-ate ①[动词后缀] 表示做.造成.使之成....做...事等意义 hyphenate 加连字符 o ...