Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 下面的脚本做什么_Javascript_Yahoo - Fatal编程技术网

Javascript 下面的脚本做什么

Javascript 下面的脚本做什么,javascript,yahoo,Javascript,Yahoo,我有一个页面,当我将鼠标移到链接上时,它会在页面的另一部分更改一个图像和一些html。但是,我想知道这个脚本是如何工作的,当我看到页面顶部的脚本时: <script type="text/javascript"> var CONTENT_CURRENT = 0; showContent = function() { if (CONTENT_CURRENT > 0) { var o = YAHOO.util.Dom.g

我有一个页面,当我将鼠标移到链接上时,它会在页面的另一部分更改一个图像和一些html。但是,我想知道这个脚本是如何工作的,当我看到页面顶部的脚本时:

  <script type="text/javascript">
    var CONTENT_CURRENT = 0;

    showContent = function() {
        if (CONTENT_CURRENT > 0) {
            var o = YAHOO.util.Dom.get('content' + CONTENT_CURRENT);
            o.style.display = 'none';

            var a = YAHOO.util.Dom.get('link' + CONTENT_CURRENT);
            a.style.color = '#46689e';
        }
        var c = YAHOO.util.Dom.get('content' + arguments[0]);
        c.style.display = 'block';

        var l = YAHOO.util.Dom.get('link' + arguments[0]);
        l.style.color = '#000000';

        CONTENT_CURRENT = arguments[0];
    };

    YAHOO.util.Event.onDOMReady(function() { showContent('1'); });
  </script>

var内容_电流=0;
showContent=函数(){
如果(当前内容>0){
var o=YAHOO.util.Dom.get('content'+content\u CURRENT);
o、 style.display='none';
var a=YAHOO.util.Dom.get('link'+CONTENT\u CURRENT);
a、 style.color='#46689e';
}
var c=YAHOO.util.Dom.get('content'+参数[0]);
c、 style.display='block';
var l=YAHOO.util.Dom.get('link'+参数[0]);
l、 style.color='#000000';
CONTENT_CURRENT=参数[0];
};
YAHOO.util.Event.onDOMReady(函数(){showContent('1');});
这个脚本如何设置页面上的a元素?实际页面位于:


在“流式软件产品”的标题下,…

还有一个代码块,您需要查看才能理解此代码

  <div class="real-products-mid-lh">
    <a id="link5" href="/products/helix_server.aspx" onmouseover="showContent('5')">Helix Server</a><br />
    <a id="link1" href="/products/rlp.aspx" onmouseover="showContent('1')">Real License Program</a><br />
    <a id="link2" href="/products/helix_security_manager.aspx" onmouseover="showContent('2')">Helix Security Manager</a><br />
    <a id="link3" href="/products/real_player_enterprise_manager.aspx" onmouseover="showContent('3')">RealPlayer Enterprise</a><br />
    <a id="link4" href="/products/helix_mobile_server.aspx" onmouseover="showContent('4')">Helix Mobile Server</a><br />
    <a id="link6" href="/products/helix_proxy.aspx" onmouseover="showContent('6')">Helix Proxy</a><br />
    <a id="link7" href="/products/real_producer.aspx" onmouseover="showContent('7')">RealProducer</a><br />
    <a id="link8" href="/products/capture_station.aspx" onmouseover="showContent('8')">Accordent Capture Station</a><br />
    <a id="link9" href="/products/elp.aspx" onmouseover="showContent('9')">Real Education Licensing</a><br />
    <a id="link10" href="/products/helix_mobile_producer.aspx" onmouseover="showContent('10')">Helix Mobile Producer</a>
  </div>










在这里,列表中的每个链接都使用索引作为参数调用showContent。下面有一堆像这样的div:

 <div id="content1" style="display:none;">
          <div class="real-products-mid-rh">
            <div class="real-products-logos">
              <table width="100%" cellpadding="0" cellspacing="0" style="border:1px solid #d6d6d6; height:107px;">
                <tr>
                  <td align="center"><a href="/products/rlp.aspx"><img src="/_common/images/logo_real_sm.gif" alt="Real License Program" style="vertical-align:middle" /></a></td>
                </tr>
              </table>
              <table width="100%" cellpadding="0" cellspacing="0" style="border-left:1px solid #d6d6d6; border-right:1px solid #d6d6d6; border-bottom:1px solid #d6d6d6; padding-top:5px; padding-bottom:5px;">
                <tr align="center">
                  <td><a href="/products/rlp.aspx"><strong>LICENSE PROGRAM</strong></a></td>
                  <td><a href="/products/rlp.aspx"><img src="/_common/images/px_more.gif" alt="Find out more" /></a></td>
                  <td>&nbsp;</td>
                </tr>
              </table>
            </div>
            <p><strong>Cost effective and all encompassing RealNetworks License Programme available exclusively to UK enterprise customers<br />
              <a href="/products/rlp.aspx">Real License Program &nbsp; <img src="/_common/images/px_more.gif" alt="Find out more" /></a></strong></p>
          </div>
      </div>

成本效益高且包罗万象的RealNetworks许可证计划仅适用于英国企业客户

该div的ID是“content1”。因此showContent函数有三个功能:

  • 如果有一个内容div 可见,使其隐藏 (显示=无)
  • 将所需的内容设置为div 看得见
  • 设置当前可视内容 索引
  • 这会导致链接右侧的内容在鼠标悬停时发生更改。

    YAHOO.util.Dom.get()
    的工作原理类似于
    document.getElementById()

    o.style.display = 'none';  // hides current content
    a.style.color = '#46689e'; // paints current link blue
    c.style.display = 'block'; // displays new content
    l.style.color = '#000000'; // paints new link black