|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
mozilla x IE js problems
Hi everybody...
I`m new here. But it`s seems a great forum about web development. :] Ok... I have done some script code that runs perfectly on IE but doesn`t work in Mozilla. It change a "img" when the user clicks the corresponding link. Here`s my js: Code:
function fixaZoom()
{
eval("$('cidadeImg').src = 'includes/images/cidade.gif'");
eval("$('regiaoImg').src = 'includes/images/regiao.gif'");
eval("$('bairroImg').src = 'includes/images/bairro.gif'");
eval("$('avenidasImg').src = 'includes/images/avenidas.gif'");
eval("$('quadrasImg').src = 'includes/images/quadras.gif'");
eval("$('ruasImg').src = 'includes/images/ruas.gif'");
switch(zoomLevel)
{
case 1:
eval("$('cidadeImg').src = 'includes/images/cidade-over.gif'");
eval("$('zoom_txt').src = 'includes/images/zoom_txt_cidade.gif'");
break;
case 2:
eval("$('regiaoImg').src = 'includes/images/regiao-over.gif'");
eval("$('zoom_txt').src = 'includes/images/zoom_txt_regiao.gif'");
break;
case 3:
eval("$('bairroImg').src = 'includes/images/bairro-over.gif'");
eval("$('zoom_txt').src = 'includes/images/zoom_txt_bairro.gif'");
break;
case 4:
eval("$('avenidasImg').src = 'includes/images/avenidas-over.gif'");
eval("$('zoom_txt').src = 'includes/images/zoom_txt_avenidas.gif'");
break
case 5:
eval("$('quadrasImg').src = 'includes/images/quadras-over.gif'");
eval("$('zoom_txt').src = 'includes/images/zoom_txt_quadras.gif'");
break;
case 6:
eval("$('ruasImg').src = 'includes/images/ruas-over.gif'");
eval("$('zoom_txt').src = 'includes/images/zoom_txt_ruas.gif'");
break;
}
}
<table width="140" border="0" cellspacing="0" cellpadding="2"> <tr align="right"> <td> <a href="javascript:zoomRadius(1)" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('cidadeImg','','includes/images/cidade-over.gif','zoom_txt','','includes/images/zoom_txt_cidade.gif',1)"> <img name="cidadeImg" border="0" src="includes/images/cidade.gif" width="15" height="12"></a></td> <td> <a href="javascript:zoomRadius(2)" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('regiaoImg','','includes/images/regiao-over.gif','zoom_txt','','includes/images/zoom_txt_regiao.gif',1)"> <img name="regiaoImg" border="0" src="includes/images/regiao.gif" width="15" height="12"></a></td> <td> <a href="javascript:zoomRadius(3)" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('bairroImg','','includes/images/bairro-over.gif','zoom_txt','','includes/images/zoom_txt_bairro.gif',1)"> <img name="bairroImg" border="0" src="includes/images/bairro.gif" width="15" height="12"></a></td> <td> <a href="javascript:zoomRadius(4)" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('avenidasImg','','includes/images/avenidas-over.gif','zoom_txt','','includes/images/zoom_txt_avenidas.gif',1)"> <img name="avenidasImg" border="0" src="includes/images/avenidas.gif" width="15" height="12"></a></td> <td> <a href="javascript:zoomRadius(5)" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('quadrasImg','','includes/images/quadras-over.gif','zoom_txt','','includes/images/zoom_txt_quadras.gif',1)"> <img name="quadrasImg" border="0" src="includes/images/quadras-over.gif" width="15" height="12"></a></td> <td> <a href="javascript:zoomRadius(6)" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('ruasImg','','includes/images/ruas-over.gif','zoom_txt','','includes/images/zoom_txt_ruas.gif',1)"> <img name="ruasImg" border="0" src="includes/images/ruas.gif" width="15" height="12"></a></td> </tr> <tr align="center"> <td colspan="6" class="texto"> <img src="includes/images/zoom_txt01.gif" width="82" height="13"><img src="includes/images/zoom_txt_quadras.gif" width="52" height="13" id="zoom_txt" name="zoom_txt"></td> </tr> </table> The "fixaZoom()" function is called from within the "MM_swapImgRestore()" function. What am i missing? Thanks in advance bb Last edited by pontonet; 03-13-2007 at 02:27 PM. |
|
#2
|
||||
|
||||
|
There is no need to use eval, get rid of it.
You should also change the name in your elements to ID since that is what you are referencing with the $. Eric
__________________
Tech Author [Ajax In Action, javascript: Visual Blueprint] | twitter | linkedin | http://www.pascarello.com |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|