Endsem Exam Questions: Unit 6
Window and Frame Architecture
Q1. Explain the structural authority of the window object in client-side JavaScript.
The window object represents the absolute apex of the execution hierarchy. It is the global execution context for client-side JavaScript. Every global variable, function, and object instantiated resides as a direct property of the window object. The document (DOM) itself is merely the window.document property. The execution engine assumes the window context implicitly.
Q2. Detail the architectural obsolescence of HTML frames.
Historically, the <frameset> element subdivided the viewport, loading discrete URLs into separate <frame> sectors.
This architecture caused catastrophic failures. It decoupled the URL in the address bar from the active content states within the frames. Users could not bookmark specific views. Search engines failed to index the isolated content. Accessibility screen readers failed to parse the subdivided logic. Modern specifications deprecate frames entirely. Developers use <iframe> elements for isolated context execution, governed by strict Cross-Origin Resource Sharing (CORS) security policies.
Form Handling and Validation
Q3. Explain the execution logic for extracting data from standard form fields.
JavaScript extracts user input state primarily via the value property. For text inputs and textareas, element.value returns the literal string. For select menus, it returns the value of the currently active <option>.
Checkboxes and radio buttons require structural deviation. Their value property remains static. JavaScript evaluates their logical state using the boolean element.checked property.
Q4. Detail the execution flow of client-side form validation.
Client-side validation intercepts the native form execution. JavaScript binds an event listener to the submit event of the <form> container.
The validation logic executes against the extracted input values. If validation fails, JavaScript executes event.preventDefault(). This halts the browser’s native HTTP POST/GET request and modifies the DOM to display error parameters. Client-side validation is strictly an interface enhancement for User Experience (UX); it provides zero security guarantees and must be duplicated by the server.
Q5. Explain the execution of dynamic form generation.
Static forms provide rigid interfaces. JavaScript executes dynamic generation to inject fields in real-time based on preceding user selections.
If a user selects a specific option, JavaScript evaluates the condition, executes document.createElement() to instantiate a new input field in memory, configures its attributes, and executes appendChild() to inject it directly into the active DOM. This maintains an uncluttered interface, presenting fields only when contextually necessary.