www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 03-13-2007, 02:24 PM
    pontonet pontonet is offline
    Registered User
     
    Join Date: Mar 2007
    Posts: 13
    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;
            }
        }
    And here`s my html code:
    <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.
    Reply With Quote
      #2  
    Old 03-13-2007, 07:51 PM
    A1ien51's Avatar
    A1ien51 A1ien51 is offline
    Ajax Author
     
    Join Date: May 2003
    Location: Between Baltimore and DC
    Posts: 3,403
    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
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:24 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.