Check object exists or not
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.
How to get which element clicked
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
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”>
<html xmlns=”http://www.w3.org/1999/xhtml” 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>