This repo series covers a 4-week intensive journey through DOM (Document Object Model), BOM (Browser Object Model), and Web APIs. Each week builds upon the previous, creating a complete understanding of frontend web development fundamentals and advanced browser capabilities.
Current Focus: This repository now contains till Week 3 implementations, demonstrating BOM manipulation, Window objects, Web APIs, storage solutions, and network requests through interactive applications.
๐ Concepts Covered:
- Understanding the DOM tree (Nodes & Elements)
- Selecting Elements (
getElementById
,querySelectorAll
) - Modifying Elements (
innerText
,innerHTML
,style
) - Handling Events (
addEventListener
, Event Delegation) - Creating & Removing Elements (
createElement
,appendChild
,removeChild
)
๐ป Practice Tasks:
- To-Do List App โ Add, remove, and mark tasks as completed
- Dynamic Theme Switcher โ Toggle between light and dark mode
๐ Resources:
๐ Concepts Covered:
- Window Object (
window.alert
,window.confirm
,window.prompt
) navigator
API (Detect browser & OS)location
&history
APIs (URL manipulation & navigation)setTimeout
andsetInterval
(Delays & Repeating actions)screen
API (Screen width, height, and resolution)
๐ป Practice Tasks:
- Interactive Feedback Form โ Comprehensive BOM implementation with user interaction
- Browser Environment Detection โ Using
navigator
and window methods
๐ Resources:
๐ Concepts Covered:
- LocalStorage & SessionStorage - Storing user data persistently and temporarily
- Fetch API - Modern way to make HTTP requests (
fetch()
, handling JSON responses) - XMLHttpRequest - Legacy AJAX method for network requests
- Promises & Async/Await - Making API calls easier and more readable
- WebSockets - Real-time bidirectional communication
๐ป Practice Tasks:
- Live User Dashboard โ Comprehensive Web APIs implementation
- Storage Comparison App - LocalStorage vs SessionStorage demonstration
- Random Joke Fetcher - API integration using both Fetch and XHR
- WebSocket Messenger - Real-time communication example
๐ Resources:
๐ Concepts to Cover:
- Geolocation API โ Access user's location
- Clipboard API โ Copy & paste programmatically
- Notifications API โ Show browser notifications
- Drag & Drop API โ Implement file uploads
- Intersection Observer API โ Detect element visibility (Lazy Loading)
- Mutation Observer API โ Observe DOM changes
๐ป Upcoming Projects:
- Geolocation Map โ Show user's location using the Geolocation API
- Lazy Loading Images โ Use Intersection Observer API for efficient loading
๐ Resources:
This repository demonstrates concepts from Week 2 and Week 3, covering:
window.alert()
- Display alert messageswindow.confirm()
- Show confirmation dialogswindow.prompt()
- Get user input through prompts
navigator.userAgent
- Browser informationnavigator.appName
- Application namenavigator.appVersion
- Application versionnavigator.platform
- Operating system platformnavigator.onLine
- Network connectivity status
window.location.href
- Full URL manipulationwindow.location.reload()
- Page reloadingwindow.location.assign()
- URL navigationwindow.history.back()
- Browser history navigationwindow.history.forward()
- Forward navigationwindow.history.pushState()
- History API manipulation
setTimeout()
- Delayed executionsetInterval()
- Repeated executionclearInterval()
- Stop intervals
screen.width
&screen.height
- Screen dimensionsscreen.colorDepth
- Color informationscreen.pixelDepth
- Pixel depth details
localStorage.setItem()
&localStorage.getItem()
- Persistent local storagesessionStorage.setItem()
&sessionStorage.getItem()
- Session-based storage- Storage event handling and data persistence
- Fetch API - Modern HTTP requests with promises
- XMLHttpRequest - Traditional AJAX implementation
- JSON parsing -
response.json()
andJSON.parse()
- Error handling - Try-catch blocks and response validation
- Real-time Communication - Bidirectional client-server messaging
- WebSocket Events -
open
,message
,close
,error
event handling - Message Broadcasting - Sending and receiving live data
- Real-time form validation with required fields
- Dynamic feedback display using DOM manipulation
- Delete functionality with confirmation dialogs
- LocalStorage integration for persistent feedback storage
- Responsive design that works on all devices
- Smooth animations and modern UI/UX
- Storage Comparison - Side-by-side LocalStorage vs SessionStorage demonstration
- API Integration - Chuck Norris jokes fetched from external API
- Dual Request Methods - Both modern Fetch API and legacy XMLHttpRequest
- Real-time WebSocket - Live messaging with echo server
- Error Handling - Comprehensive try-catch blocks and user feedback
- Clean Modern UI - Responsive design with intuitive user experience
- Pure JavaScript (Vanilla JS) - No frameworks or libraries
- Modern Web APIs - Storage, Fetch, WebSockets implementation
- CSS3 with modern features - Grid, Flexbox, Animations
- HTML5 semantic structure - Accessible and semantic markup
- Event handling and DOM manipulation - Interactive user interfaces
- Error handling - Comprehensive try-catch blocks
- Asynchronous Programming - Promises, async/await, and callbacks
DOM-BOM-WEB-APIs/
โโโ index.html # Week 2: Main feedback form HTML
โโโ script.js # Week 2: DOM manipulation & form handling
โโโ styles.css # Week 2: Modern CSS styling
โโโ week-2 snippets/
โ โโโ week2.script.js # Week 2: BOM/Window object examples
โโโ week-3 example/
โ โโโ index.html # Week 3: Web APIs dashboard HTML
โ โโโ script.js # Week 3: Storage, Fetch, WebSocket implementation
โ โโโ style.css # Week 3: Dashboard styling
โโโ README.md # Project documentation
- A modern web browser (Chrome, Firefox, Safari, Edge)
- Text editor or IDE (VS Code recommended)
- Basic understanding of HTML, CSS, and JavaScript
-
Clone the repository:
git clone https://github.com/khzunair/Week-2-DOM-BOM-Window-Manipulation.git
-
Navigate to the project directory:
cd Week-2-DOM-BOM-Window-Manipulation
-
Open in browser:
- Open
index.html
directly in your browser, or - Use a local server (recommended):
# Using Python python -m http.server 8000 # Using Node.js (http-server) npx http-server # Using VS Code Live Server extension # Right-click on index.html โ "Open with Live Server"
- Open
-
Access the application:
- Direct file:
file:///path/to/index.html
- Local server:
http://localhost:8000
- Direct file:
-
Fill out the feedback form:
- Enter your name in the first field
- Type your feedback in the textarea
- Click "Submit" to add your feedback
-
Interact with feedback:
- View all submitted feedback in the list below
- All feedback is automatically saved to LocalStorage
- Click the โ button to delete any feedback item
- Confirm deletion in the popup dialog
-
Explore BOM examples:
- Open browser console (F12)
- Check
week-2 snippets/week2.script.js
for window object demonstrations - See alerts, prompts, and timing functions in action
-
Test Storage APIs:
- Navigate to
week-3 example/index.html
- Enter your name in the input field
- Click "Save to LocalStorage" or "Save to SessionStorage"
- Observe the differences in data persistence
- Navigate to
-
Fetch API Demonstrations:
- Click "Get Joke (Fetch API)" to see modern HTTP requests
- Click "Get Joke (XHR)" to compare with legacy XMLHttpRequest
- Both buttons fetch random jokes from Chuck Norris API
-
WebSocket Communication:
- Observe real-time messages appearing in the WebSocket section
- Messages are sent automatically on connection
- See live bidirectional communication in action
๐ฏ Follow our comprehensive JavaScript learning path: JavaScript Frontend/Backend Development Roadmaps
๐ Detailed guide for this week's concepts: Week 2: BOM (Browser Object Model) & Window Manipulation
- HTML5 - Semantic structure and forms
- CSS3 - Modern styling, animations, and responsive design
- JavaScript (ES6+) - DOM/BOM manipulation and event handling
- Browser APIs - Window, Navigator, Location, Screen objects
// Creating and appending elements
const li = document.createElement("li");
li.innerText = `${nameInput}: ${feedbackInput}`;
feedbackList.appendChild(li);
// LocalStorage integration
let feedbackList = JSON.parse(localStorage.getItem("feedbackList")) || [];
localStorage.setItem("feedbackList", JSON.stringify(feedbackList));
// Form submission with validation
form.addEventListener("submit", function (e) {
e.preventDefault();
// Handle form data with comprehensive validation
});
// Window methods
window.alert("Welcome!");
window.confirm("Continue?");
window.prompt("Enter name:");
// Navigation
window.location.reload();
window.history.back();
// LocalStorage - Persistent storage
localStorage.setItem("username", name);
const local = localStorage.getItem("username");
// SessionStorage - Session-based storage
sessionStorage.setItem("username", name);
const session = sessionStorage.getItem("username");
// Async/await with error handling
const res = await fetch("https://api.chucknorris.io/jokes/random");
const data = await res.json();
document.getElementById("jokeDisplay").textContent = data.value;
// Traditional AJAX implementation
const xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.chucknorris.io/jokes/random");
xhr.onload = function () {
if (xhr.status === 200) {
const data = JSON.parse(xhr.responseText);
document.getElementById("jokeDisplay").textContent = data.value;
}
};
xhr.send();
// WebSocket connection and event handling
const socket = new WebSocket("wss://ws.postman-echo.com/raw");
socket.addEventListener("open", () => {
socket.send("Hello from Zunair's Class!");
});
socket.addEventListener("message", (event) => {
const li = document.createElement("li");
li.textContent = `Server: ${event.data}`;
document.getElementById("messages").appendChild(li);
});
After mastering Week 2: BOM & Window Manipulation and Week 3: Web APIs & Network Programming, you'll progress to:
- Geolocation API - Location-based features
- Clipboard API - Copy/paste functionality
- Intersection Observer - Lazy loading implementation
- Mutation Observer - DOM change detection
- React Fundamentals - Component-based architecture
- Backend Development - Node.js and Express
- Full-Stack Projects - Complete web applications
This is a learning project, but contributions are welcome:
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement
) - Commit your changes (
git commit -am 'Add new feature'
) - Push to the branch (
git push origin feature/improvement
) - Create a Pull Request
This project is open source and available under the MIT License.
This project is part of a comprehensive 4-week DOM, BOM & Web APIs course covering:
- Week 1: DOM Fundamentals & Element Manipulation โ
- Week 2: BOM & Window Object Manipulation โ
- Week 3: Web APIs, Storage & Network Requests โ
- Week 4: Advanced Web APIs & Real-World Implementation ๏ฟฝ
Each week builds comprehensive understanding:
- Foundation โ DOM mastery and element manipulation โ
- Browser APIs โ Window, Navigator, Location objects โ
- Data & Network โ Storage, Fetch API, Async operations โ
- Advanced โ Geolocation, Clipboard, Intersection Observer ๐
Course: Hayatian Computing Alumni - Web Development
Current Implementation: Week 2 & 3 (of 4)
Focus: DOM/BOM Manipulation, Window Objects, Web APIs & Network Programming
Repository: Complete Week 2-3 Implementation
Happy Learning! ๐