2010-05-06 6 views
0

avoir des problèmes avec mouseover dans Mozilla et Chrome après l'avoir fait fonctionner dans IE, à coup sûr je peux vous dire que mon code s'est parfaitement réveillé dans Chrome, parce que c'est mon navigateur par défaut et je l'ai utilisé pour le débogage lors de la création du javascipt et ça a bien fonctionné ... jusqu'à ce que j'essaie de le faire fonctionner dans IE aussi.onmouseover pour les images dans Firefox et Chrome

Ici, je poste le code complet de la page Web avec laquelle j'ai des problèmes.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebbShop.aspx.cs" Inherits="FSwebportal.WebbShop" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
<style> 
.prodShow{width: 100%; text-align:center;border:0; float:right; position:inherit; padding-left:310px;} 
#prodFollow{display:block; width:100%; height:100%; position:fixed; overflow:hidden;} 
#orderSett{display:block; position:relative; float:left; padding-top:inherit;} 
.ShowBig{width:290px;height:290px; padding-top:10px;} 
.pTb{width:50px;} 
.order{background-color:Transparent;margin:3px;} 
.txtArea{border:0;overflow:auto;width:200px;height:100px;} 
.prodRow{background-image:url("produktbakgrund.png"); background-repeat:repeat;} 
.row{background-color:Transparent;width:100%;margin: 0px auto;display:inline-table;} 
.col{background-color:Transparent;width:100%;margin:3px;} 
</style> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
     <center><input type="button" value="Visa allt" onclick="javascript:appendRow()" class="append_row" /></center> 
     <hr /> 

     <div id="prodFollow"> 
      <table id="dumbTable"> 
       <tr> 
        <td> 
         <img id="sideImg" class="ShowBig" src="" alt=""/> 
        </td> 
       </tr> 
       <tr> 
        <td> 
         <h3><b>Specifikationer:</b></h3> 
         <select name=""> 
         </select> 
        </td> 
       </tr> 
      </table> 
     </div> 

     <table id="itemList" class="prodShow" cellspacing="0"> 
      <thead> 
       <tr class="prodRow"> 
        <th>Bild</th> 
        <th>Förklaring</th> 
        <th>Artikelnummer</th> 
        <th>Pris</th> 
       </tr> 
      </thead> 
     </table> 

     <script type="text/javascript"> 
       function appendRow() { 
        var tbl = document.getElementById('itemList'); 


        var len = <%= aspInfo.Count %>; 
        var arr = new Array(len); 
        var currIndex = 0; 
        var imgID=0; 

        <% 
         for (int x = 0; x < aspInfo.Count; x++) { 
           Response.Write("arr["+x+"]= '"+ aspInfo[x]+"';"); 
         } 
        %> 

        for(row =0; row < arr.length/4;row++) 
        { 
        var rad = tbl.insertRow(tbl.rows.length); 
        rad.setAttribute('class','prodRow'); 
         for (c = 0; c < tbl.rows[row].cells.length; c++) 
         { 
           if(c < 1) 
           { 
            createCell(rad.insertCell(c), arr[currIndex], 'col',imgID); 
            imgID++; 
           } 
           else { 
            if(c < 3) 
            { 
             createCell(rad.insertCell(c),"<Label class=txtArea>" + arr[currIndex] + "</Label>", 'row',imgID); 
            } 
            else 
            { 
             createCell(rad.insertCell(c),"<Label class=txtArea>" + arr[currIndex] + " SKR</Label><br>Antal:<input type=text class=pTb /><input type=button width=100px value='Lägg i varukorg'></input>", 'order',imgID); 
            } 
           } 
           currIndex++; 
         } 
        } 
       } 

       function createCell(cell, text, style,imgID) { 
        if (style == 'col') { 
         var arrLen = <% = largeImg.Count %>; 
         var imgArr = new Array(arrLen); 

         <% 
         for (int x = 0; x < largeImg.Count; x++) { 
           Response.Write("imgArr["+x+"]= '"+ largeImg[x]+"';"); 
         } 
         %> 

         var div = document.createElement('div'); 
         div.setAttribute('class', style); 
         div.setAttribute('className', style); 
         div.innerHTML = "<a href='#'><img id='" + imgID + "' src='" + text + "' onmouseover=javascript:onImg('" + imgArr[imgID] + "') border='0' alt='Animg' /></a>"; 
         cell.appendChild(div); 
        } 
        else { 
         var div = document.createElement('div'); 
         div.setAttribute('class', style); 
         div.setAttribute('className', style); 
         div.innerHTML = text; 
         cell.appendChild(div); 
        } 
       } 
    </script> 
    <script type="text/javascript" language="javascript"> 
        function onImg(bigImg) { 
         var img = document.getElementById('sideImg#'); 
         img.src = bigImg; 

         alert(img.src.toString()); 
        } 
    </script> 
    </form> 
</body> 
</html> 

J'espère que vous pouvez le résoudre pour moi, devenir fou!

meilleures salutations David

+0

S'il vous plaît modifier le message pour afficher le code CSS correctement – John

Répondre

0
// wrong var img = document.getElementById('sideImg#'); 


var img = document.getElementById('#sideImg'); 

Hope this helps

0

Merci pour votre réponse John. J'ai compris le problème, et ce n'était pas le code qui était faux. C'était ma faute, créé un div pour contenir une photo sur le côté gauche. Problème était que le div ne pensait pas que le côté gauche était suffisant, mais couvert toute la largeur de la page en cachant les images derrière: P Eh bien, espérons que cela aide quelqu'un d'autre à faire la même erreur à l'avenir.

David

concerne
+0

pourquoi ne pas accepter votre réponse alors :-) – Peter

Questions connexes