|
|
.Net | PHP | Mysql | Java script
Javascript interview questions
- How do you convert the string value into number in JavaScript?
Use the parseInt() function
- What does isNaN function do?
Return true if the argument is not a number.
- How do you create a new object in JavaScript?
var obj = new Object();
- How do I clear a form after the user submits it?
use reset()
Eg:- document.forms[0].reset();
- How do I open the browser window with JavaScript?
use window.open();
- How do I close the browser window with JavaScript?
use window.close();
- How do I maximize the browser window in JavaScript?
window.moveTo(x,y) - Coordinates on the screen are counted from left to right and from top to bottom, and the horizontal coordinate is given first. AND
window.resizeTo(screen.width, screen.height); - screen.width and screen.height are built-in properties of the browser's screen object, which tell us how wide and tall the screen is. By calling the built-in function window.resizeTo with these values, we resize the browser to fill the screen.
- How do I close the browser window with JavaScript?
use window.close();
- How do I set the user's home page with JavaScript?
document.setHomePage("http://www.mysite.com");
- How do I generate a random number with JavaScript?
use Math.floor()
Eg:- var randomnumber=Math.floor(Math.random()*11)
- How to I access images using JavaScript?
document.images[0] - will get first image
Eg: - <img name="imagename" src="iamgename.gif" >
To access this image,
document.images["imagename"]
OR
document.images.imagename
|
|
|