»
EnglishFrenchVietnamese

Print - Varying Destination Button - JavaScriptBank.com

Full version: jsB@nk » Form » Button » Varying Destination Button
URL: https://www.javascriptbank.com/varying-destination-button.html

Varying Destination Button © JavaScriptBank.comUseful if you don't have much space to play with. This script almost works in Netscape 2.x: the button appears and the destination cycles properly, so clicking on the button will take you to the current destination. Unfortunately the destination is not shown on the button: it shows '{lineText}' instead.

Full version: jsB@nk » Form » Button » Varying Destination Button
URL: https://www.javascriptbank.com/varying-destination-button.html



JavaScript
<SCRIPT language=JavaScript> <!-- //author: Jan_P@dds.nl  var timerID = null var timerRunning = false var charNo = 0 var charMax = 0 var lineNo = 0 var lineMax = 3 var lineArr = new Array(lineMax) var urlArr = new Array(lineMax) lineArr[1] = "Home Page"                   urlArr[1] = "http://javascriptbank.com" lineArr[2] = "Site # 1"                   urlArr[2] = "http://javascriptbank.com" lineArr[3] = "Site # 2"                   urlArr[3] = "http://javascriptbank.com"  var lineText = lineArr[1]  function StartShow() { StopShow() ShowLine() timerRunning = true }  function FillSpaces() { for (var i = 1; i <= lineWidth; i++) { spaces += " " } }  function StopShow() { if (timerRunning) { clearTimeout(timerID) timerRunning = false } }  function ShowLine() { if (charNo == 0) { // Next line  if (lineNo < lineMax) { lineNo++ } else { lineNo = 1 } lineText = lineArr[lineNo] charMax = lineText.length } if (charNo <= charMax) { // Next char  document.formDisplay.buttonFace.value = lineText.substring(0, charNo) charNo++ timerID = setTimeout("ShowLine()", 100) } else { charNo = 0 timerID = setTimeout("ShowLine()", 3000) } }  function GotoUrl(url) { top.location.href = url } //-->   </SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<SCRIPT language=JavaScript> <!-- document.write("<form name='formDisplay'>"); document.write("<input type='button' name='buttonFace' value='&{lineText}' size=18 onClick='GotoUrl(urlArr[lineNo])'>"); document.write("</form>"); StartShow(); //-->   </SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->