Sunday 9 November 2014

odesk and elance dhtml test answers

According to wikipedia.org

  1. Dynamic HTML, or DHTML, is an umbrella term for a collection of technologies used together to create interactive and animated web sites by using a combination of a static markup language, a client-side scripting language, a presentation definition language, and the Document Object Model.
As a web developer if you pass  odesk and elance dhtml test you will get web development job easily.
odesk and elance dhtml test answers

Here all question set and odesk and elance dhtml test answers


Question:
You have two images of buttons, one bright and the other one dull. You want to change the dull image into a bright one. Which of the following attributes would you use with the img tag?


a.         onmousedown=”this.src=’bright.gif’”
onmouseup=”this.src=’dull.gif’”
b.        onmousedown=”bright.gif”
onmouseup=”dull.gif”
c.         onmouseup=”this.src=’bright.gif’”
 onmousedown=”this.src=’dull.gif’”
Question:
This is a JavaScript function for changing the color of the text box named “txtName”:

function SetColor(col)
{ document.forms[0].txtName.style.background=col }

A DHTML page contains a table in between some text. You want to shift the table 20 pixels on the right to separate it from text. Which of the following styles would be suitable for the purpose?


a.         position:relative;
left:20PX;
b.        position:relative;
left:-20PX;
c.         position:relative;
right:-20PX;
d.        position:relative;
right:20PX;
>>Question:<<
Which of the following properties is used to redirect a visitor to another page?


a.         document.URL
b.        window.location.href
c.         document.location.href
d.        link.href
            e.         window.location
>>Question:<<

Which of the following statements is true with regard to setTimeout()?


a.         The statement(s) it executes run(s) only once
b.        It pauses the script in which it is called
c.         clearTimeout() does not stop its execution
            d.        It is required in every JavaScript function
Question:
You want to disable the selection of text on the webpage. While trying to select some text, the user should see ‘not-allowed’ cursor. Which of the following helps you implement this by using JavaScript and IE 5+ browser?


a.         <body onSelectEnd=”this.style.cursor=’not-allowed’; return true;”
onMouseup=”this.style.cursor=’default’”>
b.        <body onMouseDown=”this.style.cursor=’default’”
onSelectEnd=”this.cursor=’not-allowed’; return false;”>
c.         <body onSelectStart=”this.style.cursor=’not-allowed’; return false;”
onMouseup=”this.style.cursor=’default’”>
d.        <body onMouseup=”this.style.cursor=’not-allowed’; return false;”
onSelectStart=”this.style.cursor=’default’”>
Question:
What does the following code snippet do?

<input type=”radio” name=”r1″ value=”radio1″ onclick=”this.checked=false;alert(‘sorry’)”>


a.         The code is incorrect
b.        The code makes it necessary for the user to select the radio button
c.         The code disables the radio button
            d.        The code displays an alert when the user selects the button
Question:
You have two images of buttons, one bright and the other one dull. You want to change the dull image into a bright one. Which of the following attributes would you use with the img tag?


a.         onmousedown=”this.src=’bright.gif’”
onmouseup=”this.src=’dull.gif’”
b.        onmousedown=”bright.gif”
onmouseup=”dull.gif”
c.         onmouseup=”this.src=’bright.gif’”
 onmousedown=”this.src=’dull.gif’”
Question:
This is a JavaScript function for changing the color of the text box named “txtName”:

function SetColor(col)
{ document.forms[0].txtName.style.background=col }

How will you change the color of the text box txtName to green, only for the time that the user is pressing any key?


a.         <input type=”text” onkeydown=”SetColor(‘white’)” onkeyup=”SetColor(‘green’)” name=”txtName”>
b.        <input type=”text” onkeydown=”SetColor(‘green’)” onkeyup=”SetColor(‘white’)” name=”txtName”>
c.         <input type=”text” onkeydown=”SetColor(‘green’)” name=”txtName”>
            d.        <input type=”text” onkeydown=”SetColor(‘white’)” name=”txtName”>
Question:
What will the following code snippet do?

<form onreset=”alert(‘Please again fill the form’)”>


a.         It validates the contents of the form
b.        It prompts the user not to leave the fields of the form empty
c.         It prompts the user to fill the form once the form is cleared
            d.        None of the above
Question:
Which of the following can you use to accept user input?


a.         The prompt method
b.        The alert method
c.         A form field
            d.        The confirm method
Question:
You have embedded the document.write() method to write some text within a pair of <TD></TD> table tags. On loading the file, you get some garbled junk on the page that should contain the text. What makes this happen?


a.         The browser does not support JavaScript
b.        You are using an outdated version of the browser
c.         The browser does not support cookies
            d.        None of the above
Question:
Sliding menus can be made using DHTML?


a.         True
            b.        False
Question:
Which of the following helps you highlight some of the running text on a web page?


a.         <span style=”background-color:yellow”>
b.        <span style=”background-highlight:yellow”>
c.         <span style=”background:yellow”>
            d.        <span style=”highlight-color:yellow”>
My test screen shot
 
A DHTML page contains a table in between some text. You want to shift the table 20 pixels on the right to separate it from text. Which of the following styles would be suitable for the purpose?


a.         position:relative;
left:20PX;
b.        position:relative;
left:-20PX;
c.         position:relative;
right:-20PX;
d.        position:relative;
right:20PX;
Question:
Which of the following properties is used to redirect a visitor to another page?


a.         document.URL
b.        window.location.href
c.         document.location.href
d.        link.href
            e.         window.location
Question:
Which of the following statements is true with regard to setTimeout()?


a.         The statement(s) it executes run(s) only once
b.        It pauses the script in which it is called
c.         clearTimeout() does not stop its execution
            d.        It is required in every JavaScript function
Question:
What does the following code snippet do?

<input type=”radio” name=”r1″ value=”radio1″ onclick=”this.checked=false;alert(‘sorry’)”>


a.         The code is incorrect
b.        The code makes it necessary for the user to select the radio button
c.         The code disables the radio button
            d.        The code displays an alert when the user selects the button

>>Question<<
How will you change the color of the text box txtName to green, only for the time that the user is pressing any key?


a.         <input type=”text” onkeydown=”SetColor(‘white’)” onkeyup=”SetColor(‘green’)” name=”txtName”>
b.        <input type=”text” onkeydown=”SetColor(‘green’)” onkeyup=”SetColor(‘white’)” name=”txtName”>
c.         <input type=”text” onkeydown=”SetColor(‘green’)” name=”txtName”>
            d.        <input type=”text” onkeydown=”SetColor(‘white’)” name=”txtName”>
Question:
What will the following code snippet do?

<form onreset=”alert(‘Please again fill the form’)”>


a.         It validates the contents of the form
b.        It prompts the user not to leave the fields of the form empty
c.         It prompts the user to fill the form once the form is cleared
            d.        None of the above
Question:
Which of the following can you use to accept user input?


a.         The prompt method
b.        The alert method
c.         A form field
            d.        The confirm method
Question:
You have embedded the document.write() method to write some text within a pair of <TD></TD> table tags. On loading the file, you get some garbled junk on the page that should contain the text. What makes this happen?


a.         The browser does not support JavaScript
b.        You are using an outdated version of the browser
c.         The browser does not support cookies
            d.        None of the above
Question:
Sliding menus can be made using DHTML?


a.         True
            b.        False
Question:
Which of the following helps you highlight some of the running text on a web page?


a.         <span style=”background-color:yellow”>
b.        <span style=”background-highlight:yellow”>
c.         <span style=”background:yellow”>
 d.        <span style=”highlight-color:yellow”>
Which of the following will you use for changing the color of the textbox text with id=txtLocation to blue, on a mouseover event?
a.         txtLocation.color=”blue”
b.        document.getElementById(‘txtLocation’).color=”blue”
c.         document.getElementById(‘txtLocation’).style.color=”black”
            d.        document.getElementById(‘txtLocation’).style.color=”blue”

Question:
You want to disable the selection of text on the webpage. While trying to select some text, the user should see ‘not-allowed’ cursor. Which of the following helps you implement this by using JavaScript and IE 5+ browser?


a.         <body onSelectEnd=”this.style.cursor=’not-allowed’; return true;”
onMouseup=”this.style.cursor=’default’”>
b.        <body onMouseDown=”this.style.cursor=’default’”
onSelectEnd=”this.cursor=’not-allowed’; return false;”>
c.         <body onSelectStart=”this.style.cursor=’not-allowed’; return false;”
onMouseup=”this.style.cursor=’default’”>
d.        <body onMouseup=”this.style.cursor=’not-allowed’; return false;”
onSelectStart=”this.style.cursor=’default’”>
How would you randomly choose an element from an array named myStuff if the number of elements changes dynamically?
a.         randomElement = myStuff[Math.floor(Math.random() * myStuff.length)];
b.        randomElement = myStuff[Math.ceil(Math.random() * myStuff.length)];
c.         randomElement = myStuff[Math.random(myStuff.length)];
d.        randomElement = myStuff[Math.ceil(Math.random()*myStuff.length - 1)];
After clicking on a link, your main browser window spawns a small new window and writes some text on it. When both the window page sources are viewed, the small window page source seems identical to that of the large one. Which of the following makes this happen?
a.         The function writing to the new window did not close the document stream
b.        Windows receive the source code of the window that wrote to them
c.         Since the new window has no filename, it receives the source code of its parent
d.        None of the above
Which of the following is not considered a part of DHTML?
a.         JavaScript
b.        CSS
c.         HTML
d.        VBScript
e.        All are part of DHTML
Which of the following will you use for changing the color of a button with id=btn, to green on a mouseover event?
a.         btn.color=”green”
b.        document.getElementById(‘btn’).color=”green”
c.         document.getElementById(‘btn’).style.color=”black”
d.        document.getElementById(‘btn’).style.color=”green”
The following statements show two ways of calling a JavaScript function: i)onclick = “a()”
ii)onclick=”javascript:a()”
a() refers to a function written in JavaScript.
Which of the following statements is correct with regard to the above two statements?

a.         There is no difference between the two statements
b.        The first statement is incorrect and the second one is correct
DHTML is a standard defined by the World Wide Web Consortium.
a.         True
b.        False
You want to display an alert that contains a ‘ (single-quote) character. Which of the following characters would you use to escape the ‘ character?
a.         *
b.        \
c.         /
d.        _
e.         #
f.         %
g.         |
h.        ~
You are collecting the user’s details on a webpage form. The id has to be repeated twice on the form, but you want the user to fill it once only. If the name of the first id is id1 and the second (to be auto filled) is id2, which code will you supply to the onkeyup event of id1?
a.         document.forms[0].id1.value=document.forms[0].id2.value
b.        document.forms[0].id2.value=document.forms[0].id1.value
c.         document.id1.value=document.id2.value
d.        document.id2.value=document.id1.value
Which of the following statements with regard to CSS is correct?
a.         The positioning can be absolute, relative, or dynamic
b.        The float property for text/image can be left, right, or center
c.         The values for visibility can be true or false
d.        The display property sets how an element is displayed
The width of H1 is defined as follows: H1 {width:100px;}
How can you make the heading flip horizontally?

a.         <h1 filter(flip)>Heading</h1>
b.        <h1 style=”filter::fliph()”>Heading</h1>
c.         <h1 style=”filter:fliph()”>Heading</h1>
d.        <h1 style=”FliphFilter()”>Heading</h1>
Which of the following style properties is used to display only a part of an image?
a.         snap
b.        clip
c.         scroll
d.        visible
e.         overflow
f.         size
Which of the following properties is used to redirect a visitor to another page?
a.         document.URL
b.        window.location.href
c.         document.location.href
d.        link.href
e.         window.location
Which of the following in-built functions is useful when you want to access a form element using its id?
a.         getItem(id)
b.        getFormElement(id)
c.         getElementById(id)
d.        All of the above
You have embedded the document.write() method to write some text within a pair of <TD></TD> table tags. On loading the file, you get some garbled junk on the page that should contain the text. What makes this happen?
a.         The browser does not support JavaScript
b.        You are using an outdated version of the browser
c.         The browser does not support cookies
d.        None of the above
Consider an HTML form with a checkbox and a text field. When data is entered and the Enter key is pressed, the data seems to be lost before the user can click on the button that calls the processing function. How would you correct this programatically?
a.         Add a TYPE=HIDDEN INPUT to the form
b.        Trap the Enter keypress and return (null)
c.         Add ‘return false’ to onsubmit=”…” in the FORM tag
d.        Instruct the user not to press the Enter key
e.         Modify the ENCTYPE property of the form
You are developing an application and there is a possibility of certain users using older browser versions. You want to hide the JavaScript code in the browsers that do not support JavaScript. How would you do this?

a.         Precede the JavaScript statements with //
b.        Precede the JavaScript statements with –
c.         Enclose the statements with /* and */
d.        Use the following notation:
        <script language=”javascript”>
        <!–
        //–>
        </script>
e.         Add a <noscript> tag after the script
Which of the following is an important parameter of the wave filter?
a.         WaveSize
b.        Wavelength
c.         Strength
d.        All of the above
Which of the following code snippets is more efficient and why? <script language=”javascript”>
for(i=0;i<document.images.length;i++)
document.images[i].src=”blank.gif”;
</script>
<script language=”javascript”>
var theimages = document.images;
for(i=0;i<theimages.length;i++)
theimages[i].src=”blank.gif”
</script>

a.         Both are equally efficient
b.        The first code is more efficient as it contains less coding
c.         The first code is more efficient as it employs object caching
d.        The second code is more efficient as it employs object caching
The width of h3 is defined as follows: H3 {width:90%;}
How can you make the heading flip vertically?

a.         <h3 filter(flip)>Heading</h3>
b.        <h3 style=”filter:flipv()”>Heading </h3>
c.         <h3 style=”filter::flipv()”>Heading </h3>
d.        <h3 style=”FlipvFilter()”>Heading </h3>
You declared an array as follows: var arr;
What value would JavaScript assign to an uninitialized element of this array?

a.         NaN
b.        null
c.         undefined
d.        false
e.         0
You have created an object. How can you add a property to the object class?
a.         With the prototype() method
b.        With the prototype property
c.         It cannot be done
d.        With the this object
How is the following code useful? function validate(field)
{
var valid=”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”;
var ok=”yes”;
var temp;

for(var i=0; i < field.value.length; i++)
{
temp=”" + field.value.substring(i,i+1)
if(valid.indexOf(temp)==”-1″)
{
ok=”no”;
break;
}
}
if(ok==”no”)
{
alert(“error”);
field.focus();
}
}

a.         It will force a user to enter only numeric values
b.        It will force a user to enter only alphanumeric values
c.         It will force a user to enter only character values
d.        None of the above
               
 The width of h3 is defined as follow: H3 {width:100%;}
How can you make the heading glow?

a.         <h3 filter(glow)>Heading</h3>
b.        <h3 style=”filter:glow()”>Heading </h3>
c.         <h3 style=”filter::glow()”>Heading </h3>
d.        <h3 style=”GlowFilter()”>Heading </h3>

You are formatting your error messages using the following inline style definition: <span style=”color: red”>Error message.</span>
Now you want the error message text to be displayed in blue color. But the problem is that you are not permitted to edit the HTML code, you can only edit the imported style sheet. Which style definition will you use in the imported style sheet to achieve this?

a.         span.error{color: blue;}
b.        span.error{ color: blue !important;}
c.         span.error{ color: blue !inherit;}
d.        It is impossible. Inline styles always override imported styles


Which of the following helps you create hyperlinks without an underline?
a.         a{text-decoration:none}
b.        a{text-decoration:noline}
c.         a{text-decoration:hide}
d.        a{text-decoration:invisible}
e.         a{ font-style: normal;}
f.         a{font-style: none;}


You are designing a web site and need to set the background image for all the web pages. You want a small background image to repeat and fill up the whole background. Which of the following body styles is ideal for this?
a.         body { background: url(/images/bg.gif);
repeat: repeat-x }
b.        body { background: url(/images/bg.gif);
repeat: repeat-y }
c.         body { background-image: url(/images/bg.gif);
background-repeat: no-repeat }
d.        body { background-image: url(/images/bg.gif);} 


How would you double the image size of an Image on a mouseover event, if the original width and height are 100px and id is logo?
a.         document.getElementById(‘logo’).style.width=”200″
 document.getElementById(‘logo’).style.height=”200″
b.        document.getElementById(‘logo’).style.width=”100″
document.getElementById(‘logo’).style.height=”100″
c.         document.getElementById(‘logo’).width=”200″
document.getElementById(‘logo’).height=”200″
d.        document.getElementById(‘logo’).width=”200px”
document.getElementById(‘logo’).height=”200px”


Consider the following validate function: <script type=”text/javascript”>
function ValidateField()
{
if(document.forms[0].txtId.value ==”")
{return false;}

return true;
}
</script>
This function should be called as soon as the user leaves the field. What will you do?

a.         <input name=txtId type=”text” onreset=”return ValidateField()”>
b.        <input name=txtId type=”text” onfocus=”return ValidateField()”>
c.         <input name=txtId type=”text” onsubmit=”return ValidateField()”>
d.        <input name=txtId type=”text” onblur=”return ValidateField()”>


You do not want the end user to see the JavaScript code embedded in the HTML file when the user views the source of the HTML page. Which of the following helps you achieve this?
a.         This is not possible
b.        Use externally linked files which hold the JavaScript code
c.         Modify the headers of the page
d.        Change the MIME type of the page


Which of the following will you use for changing the color of a button with id=btn, to green on a mouseover event?
a.         btn.color=”green”
b.        document.getElementById(‘btn’).color=”green”
c.         document.getElementById(‘btn’).style.color=”black”
d.        document.getElementById(‘btn’).style.color=”green”


The width of the h4 is defined as follow: H4 {width:80%;}
How can you make the heading drop shadow?

a.         <h4 filter(shadowdrop)>Heading</h4>
b.        <h4 style=”filter:shadowdrop()”>Heading </h4>
c.         <h4 style=”filter:DropShadow()”>Heading </h4>
d.        <h4 style=”DropShadow ()”>Heading </h4>
e.         <h4 filter(dropshadow)>Heading</h4>
f.         <h4 style=”filter::shadowdrop()”>Heading </h4> 
 
 
 
 

You want to shake a link on the mouseover event. If the style position is set to relative and the anchor id is lnk1, which of the following code lines will be useful with a timer?
a.         document.getElementById(‘lnk1′).left=”0″
document.getElementById(‘lnk1′).left=”2″
b.        document.getElementById(‘lnk1′).style.left=”0″
document.getElementById(‘lnk1′).style.left=”2″
c.         document.getElementById(‘lnk1′).style.move=”0″
document.getElementById(‘lnk1′).style.move=”2″
d.        document.getElementById(‘lnk1′).right=”0″
document.getElementById(‘lnk1′).right=”2″


You have defined an image tag as follows: <img id=”ERImage” width=”100″ height=”100″ onmouseover=”ImageChange()” src=”Image1.jpg”>
How would you implement ImageChange() function, if the new image to be set for mouseover is Image2.jpg?

a.         document.getElementById(‘ERImage’).src=”Image1.jpg”
b.        document.getElementById(‘ERImage’).src=”Image2.jpg”
c.         document.getElementById(‘ERImage’).style.src=”Image1.jpg”
d.        document.getElementById(‘ERImage’).style.src=”Image2.jpg”


You are required to create a web page in which hyperlinked sub-headings are displayed. On clicking a link, the contents should get displayed dynamically. Which of the following style attributes would you use for this?
a.         visibility:hidden;
b.        visibility:display;
c.         visibility:visible;
d.        visibility:none;


You are developing a website for children. You want to format the borders of big <td> cells (as mentioned below) for some fun game: Left Border:double
Right Border:dashed
Top Border:dotted
Bottom Border:solid
Which of the following would be the correct style definition?

a.         border-style:double dotted dashed solid
b.        border-style:dotted dashed solid double
c.         border-style:dashed double solid dotted
d.        border-style:solid double dotted dashed 
 
 

No comments:

Post a Comment