Ans. I/O operations like reading or writing a file is not possible with client-side javascript. However , this can be done by coding a Java applet that reads files for the script.
38. How to detect the operating system on the client machine?
Ans. In order to detect the operating system on the client machine, the navigator.appVersion
string (property) should be used.
39. How do you submit a form using Javascript?
Ans. Use
document.forms[0].submit(); |
40. How do you target a specific frame from a hyperlink?
Ans. Include the name of the frame in the target attribute of the hyperlink.
41. What is a fixed-width table and its advantages?
Ans. Fixed width tables are rendered by the browser based on the widths of the columns in the first row, resulting in a faster display in case of large tables. Use the CSS style table-layout:fixed to specify a fixed width table. If the table is not specified to be of fixed width, the browser has to wait till all data is downloaded and then infer the best width for each of the columns. This process can be very slow for large tables.
42. Where are cookies actually stored on the hard disk?
Ans. This depends on the user’s browser and OS. In the case of Netscape with Windows OS,all the cookies are stored in a single file called
cookies.txt
c:\Program Files\Netscape\Users\username\cookies.txt
In the case of IE,each cookie is stored in a separate file namely username@website.txt.
c:\Windows\Cookies\username@Website.txt
43. What can javascript programs do?
Ans. Generation of HTML pages on-the-fly without accessing the Web server. The user can be given control over the browser like User input validation Simple computations can be performed on the client’s machine The user’s browser, OS, screen size, etc. can be detected Date and Time Handling.
44. How to set a HTML document’s background color?
Ans.
document.bgcolor |
45. In a pop-up browser window, how do you refer to the main browser window that opened it?
Ans. Use window.opener to refer to the main window from pop-ups.
46. What is the data type of variables in JavaScript?
Ans. All variables are of object type in JavaScript.
47. Methods GET and POST in HTML forms – what’s the difference?
Ans. GET: Parameters are passed in the querystring. Maximum amount of data that can be sent via the GET method is limited to about 2kb.
POST: Parameters are passed in the request body. There is no limit to the amount of data that can be transferred using POST. However, there are limits on the maximum amount of data that can be transferred in one name/value pair.
48. How to embed javascript in a web page?
Ans.javascript code can be embedded in a web page between
< script type = "text/javascript" ></ script > |
49. How to get the contents of an input box using Javascript? Ans. Use the “value” property.
var myValue = window.document.getElementById( "MyTextBox" ).value; |
50. How to determine the state of a checkbox using Javascript? Ans.
var checkedStatus = window.document.getElementById( "myCheckBox" ).checked; |
51. How to set the focus in an element using Javascript?
Ans.
function setFocus() { if (focusElement != null ) { document.forms[0].elements[ "myelementname" ].focus(); } } |
52. How to access an external javascript file that is stored externally and not embedded?
Ans. This can be achieved by using the following tag between head tags or between body tags.
< script type = "text/javascript" src = "abc.js" ></ script > |
53. What is the difference between an alert box and a confirmation box?
Ans. An alert box displays only one button which is the OK button whereas the Confirm box displays two buttons namely OK and cancel.
No comments:
Post a Comment