WEB开发网
开发学院图形图像Flash Silverlight(27) - 2.0网页之可脚本化, 与DOM的交... 阅读

Silverlight(27) - 2.0网页之可脚本化, 与DOM的交互, 与JavaScript的交互

 2009-02-16 11:57:05 来源:WEB开发网   
核心提示: JSDemo.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.

JSDemo.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Silverlight20</title>
  <style type="text/css">
    html, body
    {}{
      height: 100%;
      overflow: auto;
    }
    body
    {}{
      padding: 0;
      margin: 0;
    }
    #silverlightControlHost
    {}{
      height: 100%;
    }
  </style>
  
  <script type="text/javascript" src="../Silverlight.js"></script>
  
  <script type="text/javascript">
    function silverlightInvokeJS(name) {
      // Silverlight 调用 JavaScript 方法,在页面上显示结果
      document.getElementById('result').innerHTML += "hello: " + name + "<br />";
    }
  
    function jsInvokeSilverlight(name) {
      // JavaScript 调用 Silverlight 方法,在 Silverlight 上显示结果
      var obj = document.getElementById("xaml1").content.silverlightObject;
      obj.hello(name);
    }
  </script>
  
</head>
<body>
  <div style="font-size: 12px" id="result">
  </div>
  <div style="font-size: 12px">
    加载 Silverlight20.WebPage.JSDemo 后,测试 Silverlight 和页面 JavaScript 的交互  
    <input type="button" id="btnHello" value="HelloSilverlight" onclick="jsInvokeSilverlight('webabcd')"
      style="display: none" />
  </div>
  <div id="silverlightControlHost">
    <object id="xaml1" data="data:application/x-silverlight-2," type="application/x-silverlight-2"
      width="100%" height="100%">
      <param name="source" value="../ClientBin/Silverlight20.xap" />
      <param name="EnableHtmlAccess" value="true" />
    </object>
    <iframe style='visibility: hidden; height: 0; width: 0; border: 0px'></iframe>
  </div>
</body>
</html>

上一页  2 3 4 5 6 7 

Tags:Silverlight 网页 脚本

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接