阅读更多

6顶
0踩

Web前端

原创新闻 微软在线实验室发布Web Sandbox项目

2008-10-24 11:31 by 副主编 QQbyte 评论(0) 有8060人浏览
微软在线实验室发布了一个新项目:Web Sandbox(web沙箱)。这个团队的主管是Scott Isaacs,这是一位我们需要感谢的人,他是dhtml的主要创始人(因此有了Ajax)。

Web Sandbox项目将HTML,CSS和JavaScript放在了一个独立的盒子内,目标和Caja,AdSafe,FBJS和其他解决方案一样,让JavaScript运行更加安全。

推荐看一下例子:script error sample

更多详情查看:Web Sandbox

sandbox类似这样转换代码:

<html>

    <head>

        <title>Script Error Sample</title>

        <style>

            .sampleTitle

            {

                font-family: Segoe UI, Tahoma;

                font-size: 11pt;

                font-weight: bold;

                color: 07519A;

            }

            .scriptErrorSample

            {

                    height: 130px;

                    border: solid 1px lightgrey;

                    background: white;

                    background-repeat: repeat-x;

                    background-position: left top;

                    padding: 10px;

                    overflow-y: auto;

            }

        </style>

    </head>

    <body>

        <div id="sample" class="scriptErrorSample">

            <script type="text/javascript">

                window.clockelement = "currentTime";

                function onClick() {

                    // Try to access an inexistent element

                    window.clockelement = "currentTime2";

                }

            </script>

 

                        <p>Clicking the button will cause a scripting error. When running outside the sandbox this error effectively crashes the application stopping the clock. Within the Sandbox, the error stops only that instance.</p>

                        <p>After the error is generated, you can reload this gadget by clicking the [reload] button in the Gadget toolbar.  <input type="button" onclick="onClick()" value="Generate Error!"/></p>

            <div id="currentTime" style="font-size: 8pt; font-weight: normal; color: Gray">

            </div>

 

            <script type="text/javascript">

                window.setInterval(function() {

                    document.getElementById(window.clockelement).innerText = new Date();

                }, 999)

            </script>

        </div>

    </body>

</html>


通过客户端或者服务器端Silverlight转换为:


var settings = { css : { ".sampleTitle":{"font-family":"Segoe UI, Tahoma","font-size":"11pt","font-weight":"bold","color":"07519A"},

 ".scriptErrorSample":{"border-left-width":"1px","border-right-width":"1px","border-top-width":"1px","border-bottom-width":"1px","border-left-style":"solid","border-right-style":"solid","border-top-style":"solid","border-bottom-style":"solid","padding-left":"10px","padding-right":"10px","padding-top":"10px","padding-bottom":"10px","height":"130px","background":"white","background-repeat":"repeat-x","background-position":"left top","overflow-y":"auto"} } };

 

var headerJavaScript =

function(a)

{

    var b = a.gw(this),

        c = a.g,

        d = a.i,

        e = a.f,

        f = c(b,"document");

    d(f,"initializeHTML",[[{"body":{"c":[" ",{"div":{"a":{"id":"sample","class":"scriptErrorSample"},"c":[" ",{"script":"code1"}," ",{"p":{"c":["Clicking the button will cause a scripting error. When running outside the sandbox this error effectively crashes the application stopping the clock. Within the Sandbox, the error stops only that instance."]}}," ",{"p":{"c":["After the error is generated, you can reload this gadget by clicking the [reload] button in the Gadget toolbar. ",{"input":{"a":{"type":"button","onclick":e(function()

    {

        d(b,"onClick")

    }),"value":"Generate Error!"}}}]}}," ",{"div":{"a":{"id":"currentTime","style":{"font-size":"8pt","font-weight":"normal","color":"Gray"}},"c":[" "]}}," ",{"script":"code2"}," "]}}," "]}}]])

};

 

var metadata = {"author":"","description":"","imagepath":"","title":"Script Error Sample","preferredheight":0,"preferredwidth":0,"location":"","base":{"href":"","target":""},"scripts" : {"code1" :

function(a)

{

    var b = a.gw(this),

        c = a.g,

        d = a.s,

        e = a.f,

        f = a.v;

    f.onClick = e(function()

    {

        d(b,"clockelement","currentTime2")

    });

    d(b,"clockelement","currentTime")

},"code2" :

function(a)

{

    var b = a.gw(this),

        c = a.g,

        d = a.s,

        e = a.i,

        f = a.n,

        g = a.f,

        h = c(b,"document");

    e(b,"setInterval",[g(function()

    {

        d(e(h,"getElementById",[c(b,"clockelement")]),"innerText",f(c(b,"Date"),[]))

    }),999])

}}};

 

$Sandbox.registerCode(headerJavaScript, "0", settings, metadata);

 

var SandboxInstance = new $Sandbox(document.getElementById('g_0_0_inst'), $Policy.Gadget, "0");

 

SandboxInstance.initialize();

 
来自: ajaxian.com
6
0
评论 共 0 条 请登录后发表评论

发表评论

您还没有登录,请您登录后再发表评论

相关推荐

  • (三)基于PHP——复杂的WSDL的创建(WSDL篇)

    (三)基于PHP——复杂的WSDL的创建(WSDL篇) 标签: phpsoapbindingschemaextensionoutput 2011-11-10 15:05 1562人阅读 评论(0) 收藏 举报  分类:   WSDL(2)  版权声明:本文为博主原创文章,未经博主允许不得转载。 转载请注明出处:http://blog.c

  • WSDL文件详解(中)

    WSDL 類型與訊息區段中的 XML 結構描述WSDL 的資料類型,是根據目前 W3C Recommendation 的「XML Schema: Datatypes」(XSD)。此文件共有三種不同的版本 (1999、2000/10、與 2001),若欲指定特定 WSDL 檔案所使用的版本,請在 元素中,將其宣告為命名空間的屬性。方法如下:xmlns:xsd="http://www.w3.org/

  • React框架+cesium加载GeoWebCache发布4326WMTS服务的ArcGIS切片图层请求400问题

    使用React框架+cesium加载GeoWebCache发布4326坐标系WMTS服务的ArcGIS切片图层,以及遇到的请求400问题

  • Web Service描述语言 WSDL 详解

    为什么使用WSDL?  像Internet协议之类的标准有没有为权威所利用,或者人们这样看待它是因为顺之所获的好处远远超出了代价?曾经有许多试图建立的标准都流产了。有时候,那些还没有普遍使用的标准甚至由法令或政府规定强行推出:Ada语言就是一例。  我相信正是跟随标准所带来的好处使它广泛接受。例如,对于铁路服务来说,真正重要的是,不同公司所铺设的铁路结合到一起,或者是来自好几个公司的产品协调的工作

  • 在CXF开发的WebService接口WSDL信息中添加注释

    为什么80%的码农都做不了架构师?&gt;&gt;&gt; ...

  • java xfire指定参数名_Java编程中使用XFire框架调用WebService程序接口

    JAVA调用webservice,当你刚开始接触的时候你会觉得它是一个恶梦,特别是没有一个统一的标准实现,比起.net的那些几步就可以完成的webservice实现,我们看着JAVA的实现真是伤心啊。但就算是伤心,我们也还是要完成的。JAVA也不乏比较好的实现,如xfire,jersey,CXF。这里我们就一起来看一下xfire的实现。1)首先,当然是要下包啦,这个普通人都知道。http://x...

  • 使用Soap Toolkit及Soap协议访问WebService

    本文使用的soap toolkit 3.0直接上VB代码: Sub SoapMethod() On Error GoTo errhandler '方法1:使用soap toolkit,此方法需要安装soap toolkit3.0 Dim soapclient As Object Set soapclient = CreateObject("MSSOAP.SoapClient...

  • Axis 1.4 将WSDL文件逆向后String数组只变成String

            这些天在对一个项目扩展功能时使用Axis 1.4 将WSDL文件逆向工程后产生的字符串数组却只变成字符串 。这个估计是Axis 1.4的bug。         以下贴出将要将要逆向工程的WSDL部份内容: &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt; &amp;lt;definitions targetNamespace=&quot;se...

  • WSDL详解(一)

    WSDL文档使用web服务描述语言来定义服务。 文档包括逻辑(抽象)部分和具体部分。 抽象部分用于定义独立于实现的数据类型和消息,具体部分定义一个endpoint如何实现一个可以与外界进行交互的服务。 通常建议在写代码前定义WSDL文档和XML schema,但是这就要求对WSDL非常熟悉。 逻辑部分: 包括types,message以及portType元素。typ...

  • Wsdl文件详细介绍

    PANTONE色卡-潘通色卡-金属色色卡-GG1550.0元 【wayfoon】myeclipse 里面生成wsdl文件  Soap Binding Options 有三种方式,这就是Wsdl文件中 Style和use的组合use属性可以为literal,encoded;style可以为rpc,document,我们来对五种类型的st

  • Net的wsdl生成webservice 异常:undefined simple or complex type 'soapenc:Array'

    错误代码如下: E:\>wsimport -keep service.xml parsing WSDL... [WARNING] src-resolve: Cannot resolve the name 'soapenc:Array' to a(n) 'type definition' component.   line 505 of file:/E:/service1.xml#types

  • webservice的定义、描述和用途详解

    webservice概念介绍和使用用途,谢谢! &amp;lt;href a = &quot;maito : hezj@china.kjlink.com&quot;&amp;gt; 何泽江 @凯捷国际&amp;lt;/href&amp;gt; 一、Web Service基本概念 Web Service由两部分组成 · SOAP--Web Service之间的基本通信协议。 WSDL--Web Service描述语言,它定义了Web...

  • WebService学习教程(一)

    讲师:安涛,手机号:18201597710(微信);邮箱:at_1000@126.com Webservice Webservice就是一种远程调用技术,他的作用就是从远程系统中获取业务数据   1       课程安排 什么是webservice Webservice入门程序 Webservice的应用场景 Webservice的三要素 WSDL:web服务描

Global site tag (gtag.js) - Google Analytics