* You are viewing the archive for the ‘JavaScript’ Category

JavaScript Clock

If you are searching for JavaScript Clock to display on your website, here is the end of your search.
Following JS script will fulfill your need.

var now;

function render24FormatTime() {
if (document.theForm.show24Hrs[0].checked) {
return true;
return false;

function renderTheHours(theHour) {
if (render24FormatTime() || (theHour > 0 && theHour < 13)) { return (theHour); } if (theHour == … Continue Reading

JavaScript to check when the browser window is close

Does anyone know any way that I can use javascript to check when the browser window is close and pop-up a confirmation dailog to ask whether the user is confirm to exit the browser or change his mind to stay?
Here is the answer to above questions.
<script language=”javascript”>
window.onbeforeunload = function ()
var disp_txt = “”;

disp_txt+= “WAIT! READ THIS MESSAGE.\n\n”;
disp_txt+= “Yepie, you got the answer here.\n\n”;

return disp_txt;

JavaScript & AJAX interview questions

1. Why so JavaScript and Java have similar name?
A.  JavaScript is a stripped-down version of Java
B.  JavaScript’s syntax is loosely based on Java’s
C.  They both originated on the island of Java
D.  None of the above.

2.  When a user views a page containing a JavaScript program, which machine actually executes the script?
A.  The User’s machine running a Web browser
B.   The Web server
C.  A central machine deep within Netscape’s corporate offices
D.  None of the above

3.  ______ JavaScript is also called client-side JavaScript.
A.  Microsoft
B.  Navigator
C.  LiveWire
D.  Native

4.  __________ JavaScript is also called server-side JavaScript.
A.  Microsoft
B.   Navigator
C.  LiveWire
D.  Native

5.  What are variables used for … Continue Reading

JavaScript interview questions and answers – I

1. What’s relationship between JavaScript and ECMAScript?
Ans 1. ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.

2. What are JavaScript types?
Ans 2. Number, String, Boolean, Function, Object, Null, Undefined.

3. How do you convert numbers between different bases in JavaScript?
Ans 3. Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt (“3F”, 16);

4. What does isNaN function do?
Ans 4. Return true if the argument … Continue Reading

Split is not working in javascript

Hi Friends,
I tried to use Split javascript function in one of my function to extract the string, but it was not working as expected and was throwing ans javascript error.
I found good solution for this.

JavaScript Code:
var url = window.location.href;
url_parts = url.split(‘/’);
The code was not working and was throwing javascript error for split is not a function.
Then I changes the code as follows which works fine for me.

JavaScript Code:
var url = window.location.href;
var url_parts;
url = url.toString();
url_parts = url.split(‘/’);
Happy Coding !!