2010-07-06 86 views
2

我可以到以下.htm文件复制到我的索尼爱立信C510和鼠标悬停工作:为什么JavaScript可以在我的索尼爱立信C510浏览器上工作,但不是JavaScript + jQuery?

<script type="text/javascript"> 
    <!-- 
    if (document.images) { 
     front = new Image 
     back = new Image 

     front.src = "front.png" 
     back.src = "back.png" 
    } 
    function swapImage(thisImage,newImage) { 
     if (document.images) { 
      document[thisImage].src = eval(newImage + ".src") 
     } 
    } 
    --> 
</script> 
<img onMouseOver="swapImage('test','back')" 
onMouseOut="swapImage('test','front')" 
src="front.png" 
    border="0" 
    name="test"> 

但我不能得到任何jQuery的工作,例如,当我点击链接时,以下示例没有响应。我知道jquery-1.4.2.min.js文件在正确的地方存在,因为我复制目录中的所有文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <script type="text/javascript" src="javascript/jquery-1.4.2.min.js"></script> 
    <script type="text/javascript"> 
      $(document).ready(function() { 
      $("div > div.question").click(function() { 
       if($(this).next().is(':hidden')) { 
       $(this).next().show(); 
       } else { 
       $(this).next().hide(); 
       } 
      });  
      }); 

     </script> 
     <style> 
      div.flashcard { 
       margin: 0 10px 10px 0; 
      } 
      div.flashcard div.question { 
       background-color:#ddd; 
       width: 400px;   
       padding: 5px;  
       cursor: hand;  
       cursor: pointer; 
      } 
      div.flashcard div.answer { 
       background-color:#eee; 
       width: 400px; 
       padding: 5px;  
       display: none;   
      } 
     </style> 
    </head> 

<body> 
    <div id="1" class="flashcard"> 
    <div class="question">Who was Wagner?</div> 
    <div class="answer">German composer, conductor, theatre director and essayist, primarily known for his operas (or "music dramas", as they were later called). Unlike most other opera composers, Wagner wrote both the music and libretto for every one of his works.</div> 
    </div> 

    <div id="2" class="flashcard"> 
    <div class="question">Who was Thalberg?</div> 
    <div class="answer">a composer and one of the most distinguished virtuoso pianists of the 19th century.</div> 
    </div> 
</body> 
</html> 

我怎样才能获得的jQuery在我的索尼爱立信C510的浏览器工作,因为普通的JavaScript呢?

补充:

基于rchern的建议下,我尝试这样做:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <script type="text/javascript" src="javascript/jquery-1.4.2.min.js"></script> 
    <script type="text/javascript"> 
      $(document).ready(function() { 
       $('#test').css("background-color","lightgreen"); 
       alert("hi from jQuery"); 
      }); 

     </script> 
    </head> 

<body> 
<p>test from html</p> 

<p id="test">jquery should turn this green</p> 

</body> 
</html> 

在Firefox在桌面上显示弹出式窗口,变成线绿色,但手机上的jQuery似乎没有效果,只显示文字。

+0

您是否在桌面浏览器中尝试过它,以验证它在那里有效?你试过只是做$(document).ready(function(){alert(“hi from jQuery”);}); – 2010-07-06 23:23:58

+0

它在Firefox中工作,我会尝试其他。 – 2010-07-06 23:24:56

+0

低端设备没有jQuery所需的全部JavaScript支持。其中一些HTML/CSS也不完全支持。 – Marko 2010-07-06 23:30:22

回答

5

的C510浏览器是NetFront 3.4。

这绝对来自旧的浏览器学校,早在供应商认为它提供有关支持的内容或调试工具的文档之前。与其他旧版移动浏览器一样,使用NetFront时,您必须逐步完成渐进式测试功能,因为我们今天认为基本JavaScript(无所谓DOM)的一些内容已被破坏,出现问题时您几乎无法弄清楚它是什么。

jQuery是一个复杂的野兽,它需要一些JS和DOM允许的自由。我不希望它在当前的智能手机(WinMo 6.1.4+,iPhone,Android等)之前在移动浏览器上工作。抱歉。

相关问题