Archive

Archive for April, 2011

Check object exists or not

April 12, 2011 Leave a comment

We can check through javascript whether html element exists or not.
create this function
function checkobject(obj) {
if (document.getElementById(obj)) {
return true;
}else {
return false;
}
}

Pass element’s id in this function, this function return ‘true’ if that element exists on web page other wise return false.

 

Advertisements

How to get which element clicked

April 11, 2011 Leave a comment

We can find out which element clicked on web document.
First we need to create a function i.e
function gotElement(){
var ele = arguments[0] || window.event, origEl = ev.target || ev.srcElement;
alert(ele.tagName);//Getting  tag name of element.
}

Now call this function like this…
document.onclick = gotElement();

Whenever user click on click on document then a alert will open that contains tag name.

How to check browser has javascript enabled or not

April 7, 2011 Leave a comment

The <noscript> tag is used to provide an alternate content for users that have disabled scripts in their browser or have a browser that doesn’t support client-side scripting.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml&#8221; xml:lang=”en”>
<head>
<title>Title</title>
<noscript>
<meta http-equiv=”refresh” content=”0;url=http://www.domain.com/errorPage.php”/>
</noscript>
</head>
<body>
</body>
</html>

%d bloggers like this: