How does JavaScript add interactivity, and how are media files used on web pages?
JavaScript and media: adding interactivity with event-driven JavaScript (such as onmouseover, onmouseout and onclick), and using media files with appropriate standard file formats and compression, then testing and evaluating the website.
An SQA National 5 Computing Science answer on JavaScript and media, covering how event-driven JavaScript adds interactivity using events such as onmouseover, onmouseout and onclick, how media files (graphics, audio and video) use standard file formats and compression to manage file size, and how a website is tested and evaluated.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this key area is asking
The SQA wants you to understand how event-driven JavaScript adds interactivity to a web page, how media files use standard file formats and compression to manage their size, and how a website is tested and evaluated.
Event-driven JavaScript
This is a different model from the top-to-bottom programs of Software design and development. A web page sits and waits; when the user does something, the matching event fires and its JavaScript runs. This is what makes pages respond to the user.
These events are attached to elements on the page, and each runs a piece of JavaScript when it happens. A classic example is a "rollover": onmouseover swaps an image for a highlighted version, and onmouseout swaps it back.
Media files: formats and compression
Using a standard format means the file will work in web browsers; using compression keeps the file small. The key idea examined is the link between compression and file size, and the benefits that follow.
Testing and evaluating the website
Once the pages, links, JavaScript and media are in place, the site is tested against its functional requirements: do the links work, do the events behave correctly, do the media files load, and does the site look right across pages? It is then evaluated for fitness for purpose - whether it does everything the requirements asked for - just as software and databases are evaluated.
Why this key area matters
JavaScript events turn a static page into an interactive one, responding to what the user does. Sensible use of media formats and compression keeps the site fast and efficient. Testing and evaluation confirm the finished site meets its purpose. Together these complete the web development process from design through to a working, tested site.
How this key area is examined
Questions ask you to describe event-driven programming and name events such as onclick, onmouseover and onmouseout, or explain why media files are compressed and the benefits of smaller files. Match each event to its action, and link compression to a smaller file size and then to faster loading and lower storage and bandwidth use.
For the official course specification
The SQA publishes the full National 5 Computing Science course specification, specimen question papers and coursework tasks at sqa.org.uk. Always revise from the current specification and SQA past papers, because question style and terminology are board-specific.
Exam-style practice questions
Practice questions written in the style of SQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
SQA N5 style3 marksDescribe what is meant by event-driven programming, and name two events that JavaScript can respond to on a web page.Show worked answer →
One mark for the description and one for each of two events.
Event-driven programming means the code runs in response to events - actions by the user or the browser - rather than in a fixed order from top to bottom. The program waits for an event and then runs the code attached to it.
Two events JavaScript can respond to: onclick (the user clicks an element) and onmouseover (the pointer moves over an element). onmouseout is also acceptable.
Markers reward the idea that code runs in response to events, plus two genuine events such as onclick, onmouseover or onmouseout.
SQA N5 style3 marksExplain why media files such as photographs and videos are often compressed before being put on a website.Show worked answer →
Three marks for linked points about file size, loading and storage.
Media files such as photographs and videos are large, so they are compressed to reduce their file size.
Smaller files download and load faster, especially on slow connections, improving the visitor's experience.
They also use less storage and less bandwidth. A good answer links compression to a smaller file size and then to faster loading and lower storage/bandwidth use.
Markers reward the chain: compression reduces file size, which makes pages load faster and saves storage and bandwidth.
Related dot points
- Web analysis and design: identifying end-user and functional requirements, and designing the structure and page layouts of a website using a wireframe and a navigation structure.
An SQA National 5 Computing Science answer on web analysis and design, covering how to identify end-user and functional requirements for a website, how to design page layouts with a wireframe, and how to plan the navigation structure that links the pages together.
- HTML and CSS: building page content and hyperlinks with HTML elements, and controlling appearance with CSS using element, class and id selectors and common properties.
An SQA National 5 Computing Science answer on HTML and CSS, covering how HTML elements build the structure and content of a page including headings, paragraphs, images and hyperlinks, and how CSS controls appearance using element, class and id selectors with common properties such as colour, font and size.
- Low-level operations and data representation: representing positive integers in binary, characters using a code such as ASCII, real numbers using floating point (mantissa and exponent), and graphics as bit-mapped or vector data.
An SQA National 5 Computing Science answer on low-level operations and data representation, covering how positive integers are stored in binary, how characters are stored using a code such as ASCII, how real numbers are stored using floating point with a mantissa and exponent, and how graphics are stored as bit-mapped or vector data.
- Computational constructs: assignment, arithmetic, comparison and logical operators, concatenation, predefined functions, and the control structures of selection and iteration (fixed and conditional).
An SQA National 5 Computing Science answer on computational constructs, covering assignment, arithmetic, comparison and logical operators, string concatenation, predefined functions, and the control structures of selection (IF) and iteration (fixed and conditional loops) used to build programs in a high-level language.
- Testing with normal, extreme and exceptional test data; the three kinds of error (syntax, execution and logic); and evaluating software for fitness for purpose, efficiency, robustness and readability.
An SQA National 5 Computing Science answer on testing and evaluation, covering the three categories of test data (normal, extreme and exceptional), the three kinds of error (syntax, execution and logic), and the four criteria for evaluating software: fitness for purpose, efficiency, robustness and readability.