Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Simple Script works with Firefox but not IE

Javascript coding ..

Moderators: macek, egami, gesf

Simple Script works with Firefox but not IE

Postby bigbug » Fri Jan 06, 2012 4:47 pm

Happy new year, every one,

Below code works perfectly with Firefox but not I.E. With I.E. When you click picture or buttons, no picture is shown. It seems "document.getElementById('photo').src=document.getElementById(mArray[preImg]).src" does not work in I.E. How can it be changed to make it worked with MS I.E.?

Thanks,

Code: Select all
<html>
 <head>
  <title> A simple dynamic content change </title>
 </head>

 <body>
<table  align=center width=1240 cellSpacing=0 cellPadding=1 border=0>
<tr><td>  <H2> me Feeling <SPAN ID=emotion>Happy</SPAN></H2></td></tr>
<tr valign=top><td><form name="adenroll" action="" method="get">
      <input key="prev" onclick="prev()"  value="<Prev" type="button">
  <IMG ID=photo SRC="../img/my.jpg" width="1024" height="686" onclick="next();">
<input key="next" onclick="next()"  value="next>" type="button"></form></td></tr></table>
  <H2><SPAN ID=e1 style="display:none">Sad</SPAN></H2>
  <IMG ID=ph1 style="display:none"  width="800" height="600" SRC="../img/my1.jpg">   

  <IMG ID=ph2 style="display:none"  width="180" height="200" SRC="../media/1/1.jpg"> 

  <IMG ID=ph3 style="display:none" width="180" SRC="../media/1/2.jpg">

  <IMG ID=ph4 style="display:none" width="600" height="891" SRC="../media/125/4lena_000013.jpg">

  <IMG ID=ph5 style="display:none" width="1024" SRC="../media/125/met-art_ry_239_6.jpg">

  <IMG ID=ph6 style="display:none" height="1024" SRC="../media/125/met-art_ry_239_17.jpg">

  <SCRIPT TYPE="text/javascript" >

  var preImg = -1;
  var mArray =['ph1','ph2','ph3','ph4','ph5','ph6'];
  function next() {
 
   if (preImg<5)
   {
      preImg++;
      document.getElementById('photo').src=document.getElementById(mArray[preImg]).src;
      document.getElementById('photo').width=document.getElementById(mArray[preImg]).width;
      document.getElementById('photo').height=document.getElementById(mArray[preImg]).height;
      emotion.innerHTML=mArray[preImg];
   }

  }

    function prev() {
 
   if (preImg>0)
   {
      preImg--;      
      document.getElementById('photo').src=document.getElementById(mArray[preImg]).src;
      document.getElementById('photo').width=document.getElementById(mArray[preImg]).width;
      document.getElementById('photo').height=document.getElementById(mArray[preImg]).height;
      emotion.innerHTML=mArray[preImg];

   }

  }
  </SCRIPT>
 </body>
</html>
bigbug
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Dec 21, 2011 5:45 pm

Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.