Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.
Disadvantages of JavaScript
Description
In this video we will discuss the disadvantages or downsides of using JavaScript.
There are two main disadvantages of JavaScript.
Security : JavaScript runs on the client machine. So a malicious user may use Javascript to do a variety of things like tracking your browsing history, stealing passwords etc. This is one of the main reasons why people disable JavaScript.
Browser Compatibility : Not all browsers treat the same piece of JavaScript in the same manner. This means the functionality and the user interface may vary from browser to browser. That is why cross-browser testing is very important. However, with JavaScript libraries like jQuery Browser Compatibility is no longer a major issue.
JavaScript Browser Compatibility Examples
Example 1 : innerText property is supported in IE & Chrome, but not in Firefox. This means the ValidatForm() JavaScript function that we worked with in Part 1, will only work in IE & Chrome but not in Firefox.
function ValidatForm()
{
var ret = true;
if (document.getElementById("txtFirstName").value == "")
{
document.getElementById("lblFirstName").innerText = "First Name is required";
ret = false;
}
else
{
document.getElementById("lblFirstName").innerText = "";
}
if (document.getElementById("txtLastName").value == "")
{
document.getElementById("lblLastName").innerText = "Last Name is required";
ret = false;
}
else
{
document.getElementById("lblLastName").innerText = "";
}
if (document.getElementById("txtEmail").value == "")
{
document.getElementById("lblEmail").innerText = "Email is required";
ret = false;
}
else
{
document.getElementById("lblEmail").innerText = "";
}
return ret;
}
For the above JavaScript function to work in all the browsers that is in IE, Chrome & Firefox, replace innerText property with textContent as shown below.
function ValidatForm()
{
var ret = true;
if (document.getElementById("txtFirstName").value == "")
{
document.getElementById("lblFirstName").textContent = "First Name is required";
ret = false;
}
else
{
document.getElementById("lblFirstName").textContent = "";
}
if (document.getElementById("txtLastName").value == "")
{
document.getElementById("lblLastName").textContent = "Last Name is required";
ret = false;
}
else
{
document.getElementById("lblLastName").textContent = "";
}
if (document.getElementById("txtEmail").value == "")
{
document.getElementById("lblEmail").textContent = "Email is required";
ret = false;
}
else
{
document.getElementById("lblEmail").textContent = "";
}
return ret;
}
There are two main disadvantages of JavaScript.
Security : JavaScript runs on the client machine. So a malicious user may use Javascript to do a variety of things like tracking your browsing history, stealing passwords etc. This is one of the main reasons why people disable JavaScript.
Browser Compatibility : Not all browsers treat the same piece of JavaScript in the same manner. This means the functionality and the user interface may vary from browser to browser. That is why cross-browser testing is very important. However, with JavaScript libraries like jQuery Browser Compatibility is no longer a major issue.
JavaScript Browser Compatibility Examples
Example 1 : innerText property is supported in IE & Chrome, but not in Firefox. This means the ValidatForm() JavaScript function that we worked with in Part 1, will only work in IE & Chrome but not in Firefox.
function ValidatForm()
{
var ret = true;
if (document.getElementById("txtFirstName").value == "")
{
document.getElementById("lblFirstName").innerText = "First Name is required";
ret = false;
}
else
{
document.getElementById("lblFirstName").innerText = "";
}
if (document.getElementById("txtLastName").value == "")
{
document.getElementById("lblLastName").innerText = "Last Name is required";
ret = false;
}
else
{
document.getElementById("lblLastName").innerText = "";
}
if (document.getElementById("txtEmail").value == "")
{
document.getElementById("lblEmail").innerText = "Email is required";
ret = false;
}
else
{
document.getElementById("lblEmail").innerText = "";
}
return ret;
}
For the above JavaScript function to work in all the browsers that is in IE, Chrome & Firefox, replace innerText property with textContent as shown below.
function ValidatForm()
{
var ret = true;
if (document.getElementById("txtFirstName").value == "")
{
document.getElementById("lblFirstName").textContent = "First Name is required";
ret = false;
}
else
{
document.getElementById("lblFirstName").textContent = "";
}
if (document.getElementById("txtLastName").value == "")
{
document.getElementById("lblLastName").textContent = "Last Name is required";
ret = false;
}
else
{
document.getElementById("lblLastName").textContent = "";
}
if (document.getElementById("txtEmail").value == "")
{
document.getElementById("lblEmail").textContent = "Email is required";
ret = false;
}
else
{
document.getElementById("lblEmail").textContent = "";
}
return ret;
}
More from User
07:58
JavaScript Basics
Kudvenkat
09:40
Where should the script tag be placed in html
Kudvenkat
06:30
Inline vs external javascript
Kudvenkat
06:02
Tools for learning JavaScript
Kudvenkat
04:15
How to debug javascript in visual studio
Kudvenkat
06:46
Disadvantages of JavaScript
Kudvenkat
Related Videos
00:59
Advantage & Disadvantages of external fertilization | Advantage & Disadvantages of external fertilization in Hindi | Advantage & Disadvantages of external fertilization biology #cityclasses
cityclasses
02:16
disadvantages of mountain dew _ disadvantages of cold drinks
Daily Fun Videos
00:58
Advantage & Disadvantages of internal fertilization | Advantage & Disadvantages of internal fertilization in Hindi #cityclasses
cityclasses
09:23
TAKE ADVANTAGE of DISADVANTAGES _Intense Motivational Video_#disadvantage #inspiration #life
spiritualityunited
00:41
Direct Cremation Disadvantages
jenylarry
00:51
Disadvantages of cell phone
Emran Khan Bwn