• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Script Interview Questions Answers

Question - 21 : - How to write a script for "Select" lists using javascript?

Answer - 21 : - 1. To remove an item from a list set it to null mySelectObject.options[3] = null; 2. To truncate a list set its length to the maximum size you desire mySelectObject.length = 2; 3. To delete all options in a select object set the length to 0. mySelectObject.leng

Question - 22 : - How do you target a specific frame from a hyperlink?

Answer - 22 : - Include the name of the frame in the target attribute of the hyperlink. <a href=”mypage.htm” target=”myframe”>>My Page</a>

Question - 23 : - How to find the selected radio button immediately using the 'this' variable?

Answer - 23 : - <script> function favAnimal(button) { alert('You like '+button.value+'s.'); } </script> <input type="radio" name="marsupial" value="kangaroo" onchange="favAnimal(this)">Kangaroo <br /><input type="radio" name="marsupial" value="Opossum" onchange="favAnimal(this)">Opossum <br /><input type="radio" name="marsupial" value="Tasmanian Tiger" onchange="favAnimal(this)">Tasmanian Tiger

Question - 24 : - What and where are the best JavaScript resources on the Web?

Answer - 24 : - The Web has several FAQ areas on JavaScript. The best place to start is something called the meta-FAQ [14-Jan-2001 Editor's Note: I can't point to it anymore, it is broken!], which provides a high-level overview of the JavaScript help available on the Net. As for fact-filled FAQs, I recommend one maintained by Martin Webb and a mini-FAQ that I maintain. For interactive help with specific problems, nothing beats the primary JavaScript Usenet newsgroup, comp.lang.javascript. Depending on my work backlog, I answer questions posted there from time to time. Netscape and Microsoft also have vendor-specific developer discussion groups as well as detailed documentation for the scripting and object model implementations.

Question - 25 : - How to create a popup warning box

Answer - 25 : - alert('Warning: Please enter an integer between 0 and 100.');

Question - 26 : - How to remove the event listener: ?

Answer - 26 : - <script type="text/javascript"><!-- document.getElementById("hitme4").removeEventListener("click", hitme4, false); // --> </script> Key Events "onkeydown", "onkeypress", "onkeyup" events are supported both in ie and standards-based browsers. <script type="text/javascript"> function setStatus(name,evt) { evt = (evt) ? evt : ((event) ? event : null); /* ie or standard? */ var charCode = evt.charCode; var status = document.getElementById("keyteststatus"); var text = name +": "+evt.keyCode; status.innerHTML = text; status.textContent = text; } </script> <form action=""> <input type="text" name="keytest" size="1" value="" onkeyup="setStatus('keyup',event)" onkeydown="setStatus('keydown',event)" /> <p id="keyteststatus">status</p> </form>

Question - 27 : - How to set the cursor to wait ?

Answer - 27 : - In theory, we should cache the current state of the cursor and then put it back to its original state. document.body.style.cursor = 'wait'; //do something interesting and time consuming document.body.style.cursor = 'auto';

Question - 28 : - How do you create a new object in JavaScript?

Answer - 28 : - var obj = new Object(); or var obj = {}; How do you assign object properties? obj["age"] = 17 or obj.age = 17.

Question - 29 : - How to make elements invisible ?

Answer - 29 : - Change the "visibility" attribute of the style object associated with your element. Remember that a hidden element still takes up space, use "display" to make the space disappear as well. if ( x == y) { myElement.style.visibility = 'visible'; } else { myElement.style.visibility = 'hidden'; }

Question - 30 : - What does javascript null mean?

Answer - 30 : - The null value is a unique value representing no value or no object. It implies no object,or null string,no valid boolean value,no number and no array object.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners