Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Ex/2021-12-09/errorHandling.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>JavaScript Errors handling</h1>
<button id="handleUserInput" onclick="handleUserInput()">Handle user input</button>
</li>
<li>
<img src="imagefound.gif" onerror="this.onerror=null;this.src='images/imagenotfound.gif';" />
<img src="imagefound.gif" onerror= "picerror()" id="errorpic" />
</li>
<li>
<p id="status"></p>
Expand Down
6 changes: 6 additions & 0 deletions Ex/2021-12-09/js/noErrorHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ function handleUserInput(){
let userInput = document.getElementById("userInput").value;
let result = JSON.parse(userInput);
alert("result: " + JSON.stringify(result));
}

function picerror(){
//let imageelement = document.getElementById("errorpic") ;
//imageelement.src=
document.getElementById("errorpic").src = "images/imagenotfound.gif"
}
33 changes: 33 additions & 0 deletions Ex/2021-12-09/mysoulotion1/errorHandling.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/styles.css">
<script src="js/noErrorHandling.js"></script>
</head>
<body onload="initPage()">
<h1>JavaScript Errors handling</h1>
<br>
<ul>
<li>
<button id="undefinedFunction" onclick="undefinedFunction()">Call undefined function</button>
</li>
<li>
<button id="wrongInput" onclick="wrongArgument('123')">Call a function with wrong argument</button>
</li>
<li>
<label for="userInput">User Input:</label>
<input type="text" id="userInput">
</li>
<li>
<button id="handleUserInput" onclick="handleUserInput()">Handle user input</button>
</li>
<li>
<img src="imagefound.gif" onerror= "picerror()" id="errorpic" />
</li>
<li>
<p id="status"></p>
</li>
</ul>
</body>
</html>
20 changes: 20 additions & 0 deletions Ex/2021-12-09/mysoulotion1/js/noErrorHandling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function initPage(){
console.log("initPage");
}

function wrongArgument(param1){
let result = param1.toLowerCase();
console.log(result);
}

function handleUserInput(){
let userInput = document.getElementById("userInput").value;
let result = JSON.parse(userInput);
alert("result: " + JSON.stringify(result));
}

function picerror(){
//let imageelement = document.getElementById("errorpic") ;
//imageelement.src=
document.getElementById("errorpic").src = "images/imagenotfound.gif"
}
Loading