//Set the style used for the red box document.write('style="position:absolute; '); document.write('left:150px; '); document.write('top:150px; '); document.write('background-color:red;">');
//--> </script>
This is a block of moving buttons <form> <input type="button" value="UP" onClick="moveUp()"> <input type="button" value="DOWN" onCLick="moveDown()"> <input type="button" value="LEFT" onClick="moveLeft()"> <input type="button" value="RIGHT" onClick="moveRight()"><BR> <input type="button" value="SHOW/HIDE Text Box" onClick="showHide()"> </form>
<script language="JavaScript"> <!-- //If Netscape close the layer tag if(navigator.appName.indexOf("Netscape") != -1) document.write("</layer>");
//If Microsoft close div tag if(navigator.appName.indexOf("Microsoft") != -1) document.write("</div>"); //-->
</script>
<script language="JavaScript"> <!-- //If Netscape create a text layer using layer tag if(navigator.appName.indexOf("Netscape") != -1) { document.write('<layer id="textBox" >'); document.write("Here is some text defined as a block"); document.write("</layer>"); }
//If Microsoft create a text block using div tag if(navigator.appName.indexOf("Microsoft") != -1) { document.write("</div>"); document.write("<div id='textBox'>"); document.write("Here is some text defined as a block"); document.write("</div>"); } //--> </script>
<script language="JavaScript"> <!--
var isNetscape = 0; var isMicrosoft = 0;
//Determine if this is a Netscape or Microsoft browser if(navigator.appName.indexOf("Netscape") != -1) isNetscape = 1; if(navigator.appName.indexOf("Microsoft") != -1) isMicrosoft = 1;
//Move the red box up 20 pixels function moveUp() { if(isNetscape) document.layers.redBox.pageY+=(-20); if(isMicrosoft)
document.all.redBox.style.pixelTop+=(-20); }
//Move the red box down 20 pixels function moveDown() { if(isNetscape) document.layers.redBox.pageY+=20; if(isMicrosoft) document.all.redBox.style.pixelTop+=20; }
//Move the red box to the left 20 pixels function moveLeft() { if(isNetscape) document.layers.redBox.pageX+=(-20); if(isMicrosoft) document.all.redBox.style.pixelLeft+=(-20); }
//Move the red box to the right 20 pixels. function moveRight() { if(isNetscape) document.layers.redBox.pageX+=20; if(isMicrosoft) document.all.redBox.style.pixelLeft+=20; }
//Hide or show the text box function showHide() { if(isNetscape) { //If text box is currently hidden then make it visible if(document.layers.textBox.visibility == "hide") document.layers.textBox.visibility="inherit"; else document.layers.textBox.visibility="hide"; } if(isMicrosoft) {
//If text box is currently hidden then make it visible if(document.all.textBox.style.visibility == "hidden") document.all.textBox.style.visibility="visible"; else document.all.textBox.style.visibility="hidden"; } }
//--> </script>
</body> </html>
Related Scripts with Example Source Code in same category :