0% found this document useful (0 votes)
26 views3 pages

11JavaScript DOM BOM Window Hinglish

The document explains the importance of DOM (Document Object Model), BOM (Browser Object Model), and the Window object in JavaScript for creating dynamic and interactive web applications. It details how the DOM represents HTML and XML documents, the BOM interacts with browser components, and the Window object represents the browser window. Additionally, it provides examples of accessing DOM elements and manipulating them using JavaScript methods.

Uploaded by

sumitmewada2410
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

11JavaScript DOM BOM Window Hinglish

The document explains the importance of DOM (Document Object Model), BOM (Browser Object Model), and the Window object in JavaScript for creating dynamic and interactive web applications. It details how the DOM represents HTML and XML documents, the BOM interacts with browser components, and the Window object represents the browser window. Additionally, it provides examples of accessing DOM elements and manipulating them using JavaScript methods.

Uploaded by

sumitmewada2410
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DOM, BOM aur Window Object in

JavaScript
Web development ki duniya me, DOM (Document Object Model), BOM (Browser Object
Model), aur Window object kaafi important concepts hain. Inhe samajhna JavaScript ke
through dynamic aur interactive web applications banane ke liye zaroori hai.

Document Object Model (DOM)


DOM ek programming interface hai jo HTML aur XML documents ko structure ke form me
represent karta hai. Iske through hum JavaScript ka use karke content, structure, aur style
ko dynamically change kar sakte hain.

Browser Object Model (BOM)


BOM browser ke parts ke sath interact karne ke liye hota hai, jaise ki location, history,
navigator, etc. Ye DOM ki tarah standardized nahi hai, isliye har browser me thoda alag ho
sakta hai.

Easy Language me: BOM ka use browser se interact karne ke liye hota hai. Browser ka root
object hota hai window object. Hum directly window ke methods ka use kar sakte hain,
lekin better readability ke liye 'window.' prefix lagana sahi hota hai.

Example: Accessing Window Properties


JavaScript Code:

console.log(window.innerWidth); // Window ki width


console.log(window.innerHeight); // Window ki height
console.log(window.location.href); // Current page ka URL
console.log(window.navigator.userAgent); // User agent string

Window Object
Window object browser window ko represent karta hai jisme HTML document loaded hota
hai. Ye client-side JavaScript ka global object hai.

Example: Opening a New Window

<button onclick="openNewWindow()">Open New Window</button>

function openNewWindow() {
window.open('https://www.codehelp.in/tutorials', '_blank');
}

Accessing DOM Elements


JavaScript me DOM elements ko access karna bahut important hai kyunki isse hum web
page ke content ko dynamically change kar sakte hain.

1. getElementById()
Ye method kisi bhi element ko uske ID se access karta hai.

Syntax:
document.getElementById('elementId');

Example:

let element = document.getElementById("codehelp1");


element.style.backgroundColor = "red";

2. getElementsByClassName()
Is method se ek class name wale multiple elements ka array milta hai.

Syntax:
document.getElementsByClassName('className');

Example:

let elements = document.getElementsByClassName("code1");


elements[0].style.backgroundColor = "red";

3. getElementsByTagName()
Is method ka use kisi specific tag ke saare elements ko access karne ke liye hota hai.

Syntax:
document.getElementsByTagName('tagName');

Example:
let paras = document.getElementsByTagName("p");
paras[1].style.backgroundColor = "lightgreen";
paras[3].style.backgroundColor = "yellow";

Conclusion
Is article me humne DOM, BOM aur Window object ke bare me samjha aur examples ke sath
dekha ki kaise hum inhe JavaScript ke through manipulate kar sakte hain. In teeno concepts
ka strong understanding JavaScript developer banne ke liye bahut important hai.

You might also like