views:

56

answers:

3

I have a simple page that has a (non-Prototype) JavaScript pop-up for login. It has been working fine. But when I add the Prototype framework to the page the pop-up quits working.

<script type="text/javascript" src="recipes/js/prototype.js"></script>
<script type="text/javascript">
var imgnum = 1;

function nextimg() {
  /* <![CDATA[ */
  imgnum++;
  if (imgnum > 5) imgnum = 1;
  var nextimg = 'recipes/img/iphone_' + imgnum + '.png';
  var nextimg2 = 'recipes/img/iphone_' + (imgnum + 1) + '.png';
  imagepreload = new Image();
  imagepreload.src = nextimg2;
  $('iphoneimg').src=nextimg;
  /* ]]> */
} 
</script>

I have tried to move the JS include to the bottom, with no luck. Any ideas?

Also, it works fine in IE but not Firefox or Safari.

+1  A: 

Prototype takes the $ function that JQuery also uses (are you using JQuery?).

See here

Upper Stage
No, I am not using jQuery only Prototype.
meme
Sorry - but I need to plug FireBug. Have you tried using it to debug the problem on FF?
Upper Stage
Step into the function to the point where you have $('iphoneimg').src=nextimg; and examine the value of $('iphoneimg').
Upper Stage
A: 

Make sure the 'iphoneimg' element exists on your page.

If firebug is not showing anything, add some alert() breakpoints to see where it silently fails.

Diodeus
Yes, it does I added the alert() through the code. The login box is what is breaking not the prototype code. So I need to look there.
meme
+1  A: 

After looking at the code for awhile I figured it out. My pop-up login box is using a toggle() function. So I renamed the toggle to toggle_box and the problem is now fixed.

meme