where we use javascript and for which purpose we use
javascript how?

Answers were Sorted based on User's Feedback



where we use javascript and for which purpose we use javascript how?..

Answer / kumar satpriya

JavaScript is scripting language used to manipulate DOM

Is This Answer Correct ?    0 Yes 1 No

where we use javascript and for which purpose we use javascript how?..

Answer / r.kumar mca

JavaScript is a full-fledged dynamic programming language that, when applied to an HTML document, can provide dynamic interactivity on websites. It was invented by Brendan Eich, co-founder of the Mozilla project, the Mozilla Foundation, and the Mozilla Corporation.

You can do pretty much anything with JavaScript. You'll start small with simple features such as carousels, image galleries, fluctuating layouts, and responses to button clicks. Eventually as you get more experienced with the language you'll be able to create games, animated 2D and 3D graphics, full blown database-driven apps, and more!

JavaScript itself is fairly compact but very flexible, and developers have written a lot of tools that sit on top of the core JavaScript language to unlock a huge amount of extra functionality with very little effort. These include:

Application Programming Interfaces (APIs) built into web browsers providing various functionality like dynamically creating HTML and setting CSS styles, or grabbing and manipulating a video stream from the user's webcam, or generating 3D graphics and audio samples.
Third-party APIs to allow developers to incorporate functionality in their sites from other properties, such as Twitter or Facebook.
Third-party frameworks and libraries you can apply to your HTML to allow you to rapidly build up sites and applications.

Is This Answer Correct ?    0 Yes 2 No

where we use javascript and for which purpose we use javascript how?..

Answer / satish mahato

There are already many solutions to the problem, each of
them using CSS to hide, move, or stack the images and the
text. The forum entries related to Joe Clark’s FIR article
propose several.

By using JavaScript, we have an opportunity none of these
solutions give us: the markup can be plain vanilla XHTML,
with no need for any special IDs or CSS tricks in it.

Non-JavaScript users will simply see the headlines as they
are, and designers still have the chance to style the
plain-text versions with CSS.

The only users whose experience is negatively affected are
those with JavaScript turned on and images turned off. These
users will see the text replacement for the image. An
exception are Mozilla users — but more on that later.
Enough talk, show us the goods

Take a look at the demo page and you’ll see the technique in
action. This is achieved by using one script together with
an array of image names.

replaceImages = new Array(
’About us|about.gif’,
’History|history.gif’,
’Contact Us|contact.gif’
);

function firdom(){
if(document.getElementsByTagName && document.createElement){
for (l=1;l<=6;l++){
h1s=document.getElementsByTagName(’h’+l);
scanandreplace(h1s,’h’+l);
}
}
}
function scanandreplace(h1s,tag){
for(i=0;i<h1s.length;i++){
for(f=0;f<replaceImages.length;f++){
chunks=replaceImages[f].split(’|’);
thish1=document.getElementsByTagName(tag)[i];
if(thish1.firstchild.nodevalue==chunks[0]){
newimg=document.createElement(’img’);
newimg.setattribute(’alt’,chunks[0])
newimg.setattribute(’src’,chunks[1])
// or newimg.src=chunks[1];
}
}
}
}
window.onload=firdom;

The array replaceImages needs to be defined either once in
an external JavaScript or for each page individually. It
tells the script which headline to replace with which image.

The text that will be replaced and the URL of the
replacement image are separated with a “|”.

In the below example, any headline with the content “About
Us” will be replaced with the image “about.gif”, any
headline with the content “History” with ”history.gif” and
so on.

replaceImages = new Array(
’About us|about.gif’,
’History|history.gif’,
’Contact Us|contact.gif’
);

All you need to know to use the technique is how to assemble
this array. Then you can add the array to your page, include
the script via its own script tag, and enjoy the graphical
headlines.

If you are not familiar with the DOM and you don’t want to
know about it, skip the next bit and proceed to “Where it
fails.”
Under the hood — how it works

So you want it more technical, then? Okay, firdom() does the
following:

First we check if our browser can deliver what we need by
testing for DOM capabilities. This prevents old browsers
from trying to do what they can’t.

if(document.getElementsByTagName && document.createElement){

Then we loop through all possible headline levels (<H1> to
<H6>) and call another function, asking that one to find and
replace all headlines with the current level.

for (l=1;l<=6;l++){
h1s=document.getElementsByTagName(’h’+l);
scanandreplace(h1s,’h’+l);
}

This function, scanandreplace(), takes each one of these
headlines and compares its content (the nodeValue of its
first child) with the text preceding the “|” in each element
of the array replaceImages.

function scanandreplace(h1s,tag){
for(i=0;i<h1s.length;i++){
for(f=0;f<replaceImages.length;f++){
chunks=replaceImages[f].split(’|’);
thish1=document.getElementsByTagName(tag)[i];
if(thish1.firstChild.nodeValue==chunks[0]){

If there is a match, we create a new image element and set
its source to the text following the “|” in the current
element of replaceImages.

To take an additional accessibility precaution, we set the
alt attribute of the new image to the text of the headline.

newImg=document.createElement(’img’);
newImg.setAttribute(’alt’,chunks[0])
newImg.setAttribute(’src’,chunks[1])

All that remains to be done is to replace the original text
content of the headline (its first child), with the newly
created image — and voila, we have graphical headlines.

thish1.replaceChild(newImg,thish1.firstChild)
}
}
}
}

Is This Answer Correct ?    11 Yes 14 No

Post New Answer

More JavaScript Interview Questions

Describe negative infinity in javascript?

0 Answers  


What is encodeuri() function?

0 Answers  


What is use of settimeout function in javascript?

0 Answers  


What is the default data type in javascript?

0 Answers  


Why is javascript so hard?

0 Answers  






In javascript chained select menus are available.first select menu is worked and others are disabled.when we select any one option then the next select menu will worked having option releated to selcted in first select menu.How it possible? what is the coading of this programme?

1 Answers  


What is the method for reading and writing a file in javascript?

0 Answers  


How to add multiple functions in javascript?

0 Answers  


What is difference == and === in javascript?

0 Answers  


Are Typescript and Javascript the same?

0 Answers  


Name the types of functions.

0 Answers  


what data type javascript supports?

0 Answers  


Categories