Notes: Answer: a
Explanation: The Document object has a URL property, which is a static string that holds the URL of the document when it was first loaded. If you want to access any element in an HTML page, you always start with accessing the document object.
372). What does the location property represent?
[A]Current DOM object [B]Current URL [C]Both DOM object and URL [D]Document
Notes: Answer: b
Explanation: The location property of a window is a reference to a Location object; it represents the current URL of the document being displayed in that window.
373). Which among the following is not a property of the Location object?
Notes: Answer: c
Explanation: The location object is part of the window object and is accessed through the window.location property. The various properties of the location object are the protocol, host, hostname, port, search, and hash.
374). What is the return type of the hash property?
Notes: Answer: d
Explanation: The hash property sets or returns the anchor part of a URL. The hash property returns the “fragment identifier” portion of the URL if there is one a hash mark (#) followed by an element ID. It is accessed by using the statement location.hash.
375). What is the function used to extract arguments from the search property of a URL?
Notes: Answer: a
Explanation: The urgArgs() function can be used to extract arguments from the search property of a URL. Search property can be accessed through the location object.
376). The decodeURIComponent() is defined by _____________
[A]Server-side JavaScript [B]Client-side JavaScript [C]Both Server-side and Client-side JavaScript [D]Service side JavaScript
Notes: Answer: b
Explanation: The decodeURIComponent() is a global function defined by client-side JavaScript. The decodeURIComponent() function decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine.
377). Which is the method that removes the current document from the browsing history before loading the new document?
Notes: Answer: c
Explanation: The replace() removes the current document from the browsing history before loading the new document. The difference between assign method and replace(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the “back” button to navigate back to the original document.
378). Why is the replace() method better than the assign() method?
Notes: Answer: d
Explanation: The difference between assign method and replace(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the “back” button to navigate back to the original document. When a script unconditionally loads a new document, the replace() method is often a better choice than assign().
379). What is the purpose of the assign() method?
[A] Only loading [B]Loading of window and display [C]Displays already present window [D]Unloading of window
Notes: Answer: b
Explanation: The assign() method of the Location object makes the window load and display the document at the URL you specify. The difference between this method and replace(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the “back” button to navigate back to the original document.
380). .The history property belongs to which object?
Notes: Answer: c
Explanation: The history property of the Window object refers to the History object for the window. The history object is part of the window object and is accessed through the window.history property.
381). What will be the output of the following JavaScript code?
1
2
3
function myFunction()
{
var x = document.getElementsByTagName("P").item(0);
alert(x.innerHTML);
}
Notes: Answer: a
Explanation: Item object Returns the element at the specified index in an HTMLCollection. The function gets the HTML content of the first
element of the document.
382). What will be the output of the following JavaScript code?
1
2
3
function myFunction()
{
var l = document.getElementsByTagName("P").length;
alert(l);
}
Notes: Answer: c
Explanation: The length property returns the number of elements in a HTMLCollection. This element is useful when you want to loop through a HTMLCollection.
383). What will be the output of the following JavaScript code?
Head
function myFunction()
{
var x = document.getElementsByTagName("P").namedItem("Element");
alert(x.innerHTML);
}
Notes: Answer: a
Explanation: The namedItem() method returns the element with the specified ID, or name, in an HTMLCollection. A shorthand method can also be used, and will produce the same result.
384). What will be the output of the following JavaScript code?
Notes: Answer: b
Explanation: The isId property returns true if the attribute is of type ID, otherwise it returns false. It is found in the DOM attribute object.
385). What will be the output of the following JavaScript code?