How can I check whether left or right mouse button has been clicked?

To determine whether the user clicked the left or right button, you can use the following properties. Event.which in Netscape Navigator event.button in Internet Explorer If the value of these properties is 1, the event occurred for the left button. In the following example, the onMouseDown event handler displays the messages Left button or Right button, depending on the mouse button you actually have clicked. The messages will appear on your browser’s status bar. Click or right-click anywhere on this page to see it work: <html> <head> <script language=’JavaScript’> <!– function mouseDown(e) { if (parseInt(navigator.appVersion)>3) { var clickType=1; if (navigator.appName==’Netscape’) clickType=e.which; else clickType=event.button; if (clickType==1) { self.status=’Left button!’; alert(‘Left Button’); } if (clickType!=1) { self.status=’Right button!’; alert(‘Right Button’); } } return true; } if (parseInt(navigator.appVersion)>3) { document.onmousedown = mouseDown; if (navigator.appName==’Netscape’) document.captureEvents(Event.MOUSEDOWN); } //–> </script> </head> </html>

How can we check whether a function exists in javascript?

We can check the existence of a function by Window.FunctionName as shown below, where the FunctionName is the name of the function,whose existence has to be checked. <SCRIPT LANGUAGE=’JavaScript’ type=’text/javascript’> functionCheckIfExists() { alert(’FunctionExists’) } if( window.CheckIfExists) { CheckIfExists() } else { alert( Function Not Exists!’ ) } </SCRIPT>

How can i resize the dialog window?

You can size a window with JavaScript using ‘window.resizeTo(valueX,valueY)’. <script> functionResizeWindow() { window.resizeTo(800,800); } </script> Note also that the parameters of resizeTo() have different meaning in different browsers: in Internet Explorer the parameters specify the outer size of the window, while in Netscape Navigator they refer to the inner size (which does not include the window borders, toolbar, status bar, title bar, and the address line). The ‘window.resizeBy()’ method is slightly different than it’s ‘resizeTo()’ which changes window’s dimensions to a certain number of pixels from it’s current size.

How can you get the X Co-ordinates Y Co-ordinates values during the Mouse Movement?

The X and y co-ordinates during the mouse movement can be obtained by the following codings. <html> <body> <form name=’Show’> <b>X Co-Ordinate Value:</b><input type=”text” name=”X” value=”0″ size=”4″> <br> <b>Y Co-Ordinate Value:</b><input type=”text” name=”Y” value=”0″ size=”4″> <br> </form> <script language=’Javascript’> <!– // Detect if the browser is IE or not. // If the browser is not IE, we assume that the browser is NS. var IE = document.all?true:false // If NetScape then set up for mouse capture if (!IE) document.captureEvents(Event.MOUSEMOVE) // Set-up to use getMouseXY function onMouseMove document.onmousemove = getMouseXY; // Temporary variables to hold mouse x-y pos.s var tempX = 0 var tempY = 0 // Main function to retrieve mouse x-y pos.s function getMouseXY(e) { if (IE) { // grab the x-y pos.s if browser is IE tempX = event.clientX + document.body.scrollLeft; tempY = event.clientY + document.body.scrollTop; } else { // grab the x-y pos.s if browser is NS tempX = e.pageX; tempY = e.pageY; } // catch possible negative values in NS4 if (tempX < 0){tempX = 0} if (tempY < 0){tempY = 0} // show the position values in the form named Show // in the text fields named MouseX and MouseY document.Show.X.value = tempX; document.Show.Y.value = tempY; return true; } //–> </script> </body> </html>

How can you make a piece of text get moving along the mouse Movement?

We can make text to move along the mouse using javascript as given below, <html> <head> <style> .spanstyle { position:absolute; visibility:visible; top:-50px; font-size:10pt; font-family:Verdana; font-weight:bold; color:black; } </style> <script> var x,y var step=20 var flag=0 var text=’Syncfusion .NET Essentials ‘ text=text.split(”) var xpos=new Array() for (i=0;i<=text.length-1;i++) { xpos[i]=-50 } var ypos=new Array() for (i=0;i<=text.length-1;i++) { ypos[i]=-50 } function handlerMM(e) { x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY flag=1 } function MoveText() { if (flag==1 && document.all) { for (i=text.length-1; i>=1; i–) { xpos[i]=xpos[i-1]+step ypos[i]=ypos[i-1] } xpos[0]=x+step ypos[0]=y for (i=0; i<text.length-1; i++)=”” {=”” var=”” spanvalue=”eval(‘span’+(i)+’.style’)” spanvalue.posleft=”xpos[i]” spanvalue.postop=”ypos[i]” }=”” else=”” if=”” (flag=”=1″ &&=”” document.layers)=”” for=”” (i=”text.length-1;” i=””>=1; i–) { xpos[i]=xpos[i-1]+step ypos[i]=ypos[i-1] } xpos[0]=x+step ypos[0]=y for (i=0; i<text.length-1; i++)=”” {=”” var=”” spanvalue=”eval(‘document.span’+i)” spanvalue.left=”xpos[i]” spanvalue.top=”ypos[i]” }=”” timer=”setTimeout(‘MoveText()’,30)” <=”” script>=”” head>=”” <body=”” onload=”MoveText()” style=”width:100%;overflow-x:hidden;overflow-y:scroll” >=”” <script>=”” for=”” (i=”0;i<=text.length-1;i++)” document.write(‘<span=”” id=”’span’+i+’’” class=”’spanstyle’”>’) document.write(text[i]) document.write(”) } if (document.layers) { document.captureEvents(Event.MOUSEMOVE); } document.onmousemove = handlerMM; </script> </body> </html> </text.length-1;></text.length-1;>