How can you resize the html elements dynamically?

Html elements can be resized dynamically by using the style properties. In the below example the TextArea size is increased dynamically on clicking the button. <html> <script language=javascript> function resize() { document.form1.TextArea1.style.height=’600px’; document.form1.TextArea1.style.width=’400px’; } </script> <form name=form1> <TextArea style=’WIDTH: 200px; HEIGHT: 200px’ name=’TextArea1′></TextArea> <input type=’button’ style=’WIDTH: 100px; HEIGHT: 100px’ name=’button1′> </form> <input type=button value=’ClickMe’ onclick=javascript:resize()> </html>

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>