0% found this document useful (0 votes)
25 views

JavaScript_Answers

Javascript answers

Uploaded by

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

JavaScript_Answers

Javascript answers

Uploaded by

Sara Waghchaure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

JavaScript Answers

1. What is the use of the status bar in a web application?

- The status bar in a web application displays information about the current state of the page, such

as loading status, URL of hovered links, and other interactive elements, providing a better user

experience.

2. State the method to put a message in the web browser status bar.

- You can use JavaScript to put a message in the status bar by using `window.status = 'Your

message here';`.

3. Write a JavaScript program that creates scrolling text on the status line of a window.

```javascript

let message = 'Welcome to our website!';

let position = 0;

function scrollText() {

window.status = message.substring(position) + message.substring(0, position);

position = (position + 1) % message.length;

setTimeout(scrollText, 150);

scrollText();

```

4. Write a program to display a JavaScript status bar message whenever users hover over your

hyperlinks.

```html

<a href="#" onmouseover="window.status='You hovered over the link!'; return true;"

onmouseout="window.status=''; return true;">Hover over this link</a>


```

5. Write a JavaScript to scroll the status bar message horizontally.

- This can be done similarly to question 3, by updating the `window.status` with a looping

message.

6. What is a banner ad?

- A banner ad is a form of online advertisement in the form of an image or animation, usually

placed at the top or side of a webpage, and is designed to attract traffic to the advertiser's site.

7. Develop a JavaScript program to create rotating banner ads with URL links.

```javascript

let ads = [

{url: 'https://example1.com', image: 'banner1.jpg'},

{url: 'https://example2.com', image: 'banner2.jpg'},

{url: 'https://example3.com', image: 'banner3.jpg'}

];

let currentAd = 0;

function rotateBanner() {

document.getElementById('banner').src = ads[currentAd].image;

document.getElementById('bannerLink').href = ads[currentAd].url;

currentAd = (currentAd + 1) % ads.length;

setTimeout(rotateBanner, 3000);

rotateBanner();

```

8. Write JavaScript to create and display a banner.

- The banner can be created using HTML and JavaScript, similar to question 7 but with only one
ad image and link.

9. Write JavaScript that illustrates linking a banner advertisement to a URL.

```html

<a href="https://example.com" target="_blank">

<img src="banner.jpg" alt="Banner Advertisement">

</a>

```

10. What is a slide show?

- A slideshow is a series of images displayed in sequence, often with transitions, used in

presentations and web pages to display content dynamically.

11. Write JavaScript to show the creation of a slideshow.

```javascript

let images = ['slide1.jpg', 'slide2.jpg', 'slide3.jpg'];

let index = 0;

function showSlide() {

document.getElementById('slideshow').src = images[index];

index = (index + 1) % images.length;

setTimeout(showSlide, 2000);

showSlide();

```

12. Explain with a suitable example how to create a pull-down menu.

- A pull-down menu can be created using the HTML `<select>` element.

```html

<select>
<option value="home">Home</option>

<option value="about">About</option>

<option value="contact">Contact</option>

</select>

```

You might also like