<-Pre | Home | Next-> |
what is JavaScript?
JavaScript is a scripting language widely used for client-side web development.
Explain about run time environment of Javascript?
Java script does not have a sophisticated run time of its own but it relies on the web browser of the client. It relies on this run time environment for its functions and methods to perform their duties by which scripts can interact with the user.
State some simple usages with Javascript?
Some of the simple usages with Javascript are
1) A new pop up window can be made and changed according to the requirements such as no menus, scroll bars, etc.
2) Validation of input values submitted by the user through a web form.
3) Mouse over effects, scroll effects etc which can be changed by the scroll of the mouse pointer over a certain image, etc.
Explain about the security functions presents in JavaScript?
As JavaScript uses Web as an interface it gives an ample scope for users to transfer malicious scripts. Most of the JavaScript related breaches and wrong doings are due to sandbox or same origin policy.
How to read and write a file using JavaScript?
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.
Explain about Cross site scripting?
Cross site scripting raises security threats during execution and secured data transfer through web sites. It uses same origin policy. When a malicious script is made to run it discloses private information to the wrong person. This occurs because some one clicks on the request sent by the wrong doer.
How do we get JavaScript onto a web page?
1.<script type="text/javascript" >
//Define variable
//Define function
</script>
2.<script language="JavaScript" type="text/javascript">
//Define variable
//Define function
</script>
3.<script>
//Define variable
//Define function
</script>
JavaScript Comment?
Single Line Comment- //This is Single Line Comment
Multi line Comment - /* This is Multi Line Comment
You have learn multi line comment.
*/
How to open a new window?
eg:To open a new window on click of a button.
< script type="text/javascript" >
function mynewWindow() {
window.open( "http://www.google.com/" );
}
< /script >
< input type="button" onClick=mynewWindow() value="NewWindow" >
OR
< a href="javascript: window.open(http://www.google.com/)">New Window </a >
What is void(0)?
void is an operator that is used to return a null value so the browser will not be able to load a new page.
which operator is to compare two string?
operator == is used to compare two string.
eg: var test = "checkeq";
if(test == "checkeq")
What are the precautions taken by the web browsers to contain malicious activity with Java Script?
Java script activities are restricted by web browsers in two ways they are.
1) First scripts run in sandbox which performs the most basic functions such as executing or running the code or script. This doesn’t allow programming activities.
2) Scripts present in one site cannot have access to other sites; this is done with the help of same origin policy.How to get CheckBox status whether it is checked or not?
Write following code:
alert(document.getElementById('checkbox1').checked);
if it will be checked you will get true else false.
How to get current time in various format (i.e seconds , miliseconds,Day of month etc.)
Create a oject of Date class and use its methods.
* getTime() - Number of milliseconds since 1/1/1970 @ 12:00 AM
* getSeconds() - Number of seconds (0-59)
* getMinutes() - Number of minutes (0-59)
* getHours() - Number of hours (0-23)
* getDay() - Day of the week(0-6). 0 = Sunday, ... , 6 = Saturday
* getDate() - Day of the month (0-31)
* getMonth() - Number of month (0-11)
* getFullYear() - The four digit year (1970-9999)
eg:
<script type="text/javascript">
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write("month is "+ month + "/  " + "day is "+day +"  year is "+ "/" + year)
or
alert(month + "/" + day + "/" + year)
</script>
How do you submit a form using Javascript?
OR
How do you submit more than one form using Javascript?
Use document.forms[0].submit();
(0 refers to the index of the form ? if you have more than one form in a page, then the first one has the index 0, second has index 1 and so on).
How do you create a new object in JavaScript?
var obj = new Object(); or var obj = {};
What does "1"+2+3 evaluate to?
Since 1 is a string, everything is a string, so the result is 123.
What does 1+2+"3" evaluate to?
Since 1 and 2 are integers, this is number arithmetic, since 3 is a string, it?s concatenation, so 33 is the result.
What are undefined and undeclared variables?
Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime error.But if undeclared variables are assigned then implicit declaration is done .
Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such variables gives special value called undefined value.
Are Java and JavaScript the Same?
No.java and javascript are two different languages. Java is a powerful object - oriented programming languagelike C++,C whereas Javascript is a client-side scripting language with some limitations.What is the difference between an alert box and a confirmation box?
An alert box displays only one button which is the OK button whereas the Confirm box
displays two buttons namely OK and cancel.
Pre->Servlet | Next->XML |
*****Please feel free to give feedback at shrawan.iitg@gmail.com and comments below *****
No comments:
Post a Comment