<script type="text/javascript">
<![CDATA[
function mout()  {         alert(st1);  
 }  
 ]]>
</script>
  <object id="svg_obj" type="image/svg+xml" width="100%" height="80%" data="example_1.svg">
    Your browser is currently unable to display SVG images.
</object>      //在example_1.svg 中 嵌入 java script  st1="hello world";
   
<object id="svg_obj" type="image/svg+xml" width="100%" height="80%" data="example_2.svg">
    Your browser is currently unable to display SVG images.
</object>      //在example_2.svg 的一个mouseout事件中 mouseout=mout()   返回helloworld的字符串 如何实现呢   

解决方案 »

  1.   

    初学 java script  不是很懂,可否给个更直观的小例子
      

  2.   

    b页面
    <!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></title>
        <script src='common.js'></script>
    </head>
    <body>
    <script>
        a('b');
    </script>
    </body>
    </html>
    a页面:
    <!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></title>
        <script src='common.js'></script>
    </head>
    <body>
    <script>
        a('a');
    </script>
    </body>
    </html>
    共用js:
    function a(value) {
        alert(value);
    }
    没弄过svg,我想也应该差不多
      

  3.   

    右键 项目或项目内的文件夹-添加-新建项-web-Jscript文件
    输入文件名后确定,即添加了一个js文件,写入代码保存
    也可以用文本文件,后缀名改为.js页面上引用方式:
    <script type="text/javascript" src="../js/WebBase.js" ></script>src 即js文件在项目内的路径引用该js文件等效于在页面该位置添加了文件内的代码