ExamBank Scot · Higher Computing Science question bank · All Higher Computing Science questions

Higher Computing Science 2026 Question 18

10 marks · JavaScript mouse events

Write an additional JavaScript function to change the old badge back to the new badge. Re‑write the HTML code to call the function displayOld when the mouse is placed over the new badge and to call the JavaScript function from part (i) when the mouse moves off the image. Part of the HTML code for the ‘About us’ web page is shown below. <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <header> <h1>Moreland Football Club</h1> <img src="morelandsNB.png"> </header> ... <main> <h1>About us</h1> ... When tested, this code displays the header of the web page as shown below. About us The club badge should be displayed beside the name of the club as shown below. About us Write the CSS rule for the h1 tag within the header element to display the club badge beside the name of the club. Some CSS rules for the website are shown below. header {height: 200px; margin‑top: 10px;} footer {margin‑top: 10px; height: 40px;} #stadiumImg {float:left; width:590px; height:600px} #infoSection {float:left; width:590px; height:600px} Using grouping selectors re‑write this code to make it more efficient. The ‘Sponsor’ page contains a form that allows users to sponsor one or more of the club’s 20 players. The form element that allows users to choose who to sponsor is a drop‑down list. Describe two reasons for using a drop‑down list rather than radio buttons for this element. Morelands Football Club are launching a new badge on the home page of their website. oldBadge.png newBadge.png When the image of the new badge is clicked it is permanently changed to an image of the old badge. The HTML code and JavaScript function to implement this is shown below. HTML <img src="../images/newBadge.png" onclick="displayOld(this)" > JavaScript function displayOld(my_image){ my_image.src = '../images/oldBadge.png'; } Usability testing identified that users do not like the old badge being permanently displayed after the new badge is clicked.

Marking scheme

function displayNew(my_image){ my_image.src =' ../images/newBadge.png'; } Mark can be awarded if function correct with or without relative file path. • calling displayOld using onmouseover • calling new function using onmouseout <img src="newBadge.png" onmouseover="displayOld(thi s)" onmouseout="displayNew (this)"> New function for bullet 2 must match a(i). • header h1 • display: inline Accept float:left for bullet 2. header h1{display: inline;} • header, footer {margin-top: 10px;} • header {height: 200px;} footer {height: 40px;} • #stadiumImg, #infoSection{ float: left; width: 590px; height: 600px } • dropdown list allows multiple selection • dropdown menu takes up less space on the page Accept inverse.

Previous question: Higher Computing Science 2026 Question 17

Next question: Higher Computing Science 2026 Question 19