How can you avoid postback on submit button?
The postback on submit button can be avoided by giving return=false in the event handler function as below. <INPUT type='submit' value='Submit' onclick='return false;'>
How can you identify the drives available in the System?
The drives available in system can be identified using the following code. <HTML> <HEAD> <SCRIPT language=JavaScript> function ShowAvailableDrives() { document.write(GetDriveList()); } function GetDriveList() { var fso, s, n, e, x; fso = new ActiveXObject('Scripting.FileSystemObject'); e = new Enumerator(fso.Drives); s = ''; do { x = e.item(); s = s + x.DriveLetter; s += ':- '; if (x.DriveType == 3) n = x.ShareName; else if (x.IsReady) n = x.VolumeName; else n = '[Drive not ready]'; s += n + ' '; e.moveNext(); }while (!e.atEnd()); return(s); } </SCRIPT> </HEAD> <BODY> <P> <SCRIPT language=JavaScript> ShowAvailableDrives(); </P> </BODY> </HTML>
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.