tinfanide Posted October 16, 2011 Share Posted October 16, 2011 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><script>function show(start,end,str){clearTimeout(display);end += 1;document.getElementById("div").innerHTML = str.substring(start,end);if(end < str.length){ var display = setTimeout(show,100); } else { clearTimeout(display); }}window.onload = function(){show(-1,-1,"abcdefghij");}</script></head><body><div id="div"></div></body></html> I've always had problems with passing parameters in functions.I want to put all the variables as parameters so that I can have a function layout for whenever I need the function and I can put in different values for the same purpose.But FF Console always reports errors like object undefined or simply not working without any error report.In this case, I wonder how I can pass all the parameters. Link to comment Share on other sites More sharing options...
JamesB Posted October 16, 2011 Share Posted October 16, 2011 changing var display = setTimeout(show,100); to var display = setTimeout(function() { show(start, end, str); }, 100); should fix it. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.