Find the errors in this HTML/CSS/JavaScript application. Here is
map.jpg for the image.
<!-- HTML Page: map.htm -->
<DOCTYPE html>
<html lang="english">
<head>
<meta encoding="utf-8">
<title>Pirates Booty<title>
<script href="script.js">
<link rel="stylesheet" src="../styles.css">
</head>
<body>
<img id=map src="map.jpg">
<p id="coords">Move mouse over map to
find coordinates...</p>
</body>
</html>
--------------------------------------------------
// CSS Styles: styles.css
body { fontfamily: Verdana Tahoma sans-serif;
background; FFFFE0 ]
--------------------------------------------------
// JavaScript Script: script.js
window.onLoad = init;
function init {
val map = document.getElementById("#map");
map.onmousemove = showCoords( );
function showCoords(eventObj) {
var coords = getElementsById("coord");
var x = e.clientX;
let y = e.clientY;
coords.innerHtml = 'Map coordinates: (%{x}, %{y})';
}
Here are the corrected source code files:
--------------------------------------------------
<!DOCTYPE html>
<!-- HTML Page: map.htm -->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Pirates Booty</title>
<script src="script.js"></script>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<img id="map" src="map.jpg">
<p id="coords">Move mouse over map to
find coordinates...</p>
</body>
</html>
--------------------------------------------------
/* CSS Styles: styles.css */
body { font-family: Verdana, Tahoma, sans-serif;
background-color: #FFFFE0; }
--------------------------------------------------
// JavaScript Script: script.js
window.onload = init;
function init( ) {
var map = document.getElementById("map");
map.onmousemove = showCoords;
}
function showCoords(eventObj) {
var coords = document.getElementById("coords");
var x = eventObj.clientX;
let y = eventObj.clientY;
coords.innerHTML =
`Map coordinates: (${x}, ${y})`;
}
--------------------------------------------------