Compatibility issues with <a> and calling a function(); across different web browsers
Posted
by Matthew
on Stack Overflow
See other posts from Stack Overflow
or by Matthew
Published on 2010-04-13T18:11:33Z
Indexed on
2010/04/13
18:13 UTC
Read the original article
Hit count: 353
Hi, I am new to javascript. I wrote the following function rollDice() to produce 5 random numbers and display them. I use an anchor with click event to call the function. Problem is, in Chrome it won't display, works fine in IE, in firefox the 5 values display and then the original page w/anchor appears! I am suspicious that my script tag is too general but I am really lost. Also if there is a display function that doesn't clear the screen first that would be great.
diceArray = new Array(5)
function rollDice() { var i;
for(i=0; i<5; i++) { diceArray[i]=Math.round(Math.random() * 6) % 6 + 1;
document.write(diceArray[i]); } }
when I click should display 5 rand variables
© Stack Overflow or respective owner