0% found this document useful (0 votes)
2 views1 page

In Classweb

The document outlines an in-class activity for CSC2102 - Web Programming I, where students create a web page that allows users to input a URL and open it in a new tab. It specifies the HTML structure needed, including a form and a button, and provides JavaScript instructions for validating the URL, confirming the user's choice, and displaying a success message. The activity emphasizes user interaction through confirmation and dynamic URL handling.

Uploaded by

Geethika piumal
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)
2 views1 page

In Classweb

The document outlines an in-class activity for CSC2102 - Web Programming I, where students create a web page that allows users to input a URL and open it in a new tab. It specifies the HTML structure needed, including a form and a button, and provides JavaScript instructions for validating the URL, confirming the user's choice, and displaying a success message. The activity emphasizes user interaction through confirmation and dynamic URL handling.

Uploaded by

Geethika piumal
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/ 1

CSC2102 - Web Programming I - In class Activity

Create a web page that allows users to input a URL, confirm their choice to open the URL, and then open
the website in a new tab based on their decision.

HTML Structure:

●​ Define a form with an input field for users to enter the URL.
●​ Add a button that opens the entered URL upon click.
●​ Include a placeholder text to show success once the URL is opened.

JavaScript to Handle Button Click:

In the <script> section, implement a function that:

●​ Reads the entered URL.


●​ Checks if the URL starts with http:// or https://. If not, the function should prepend https:// to the
URL. (HINT: str.startsWith("http://") checks whether a string starts with "http://")
●​ Asks for confirmation from the user before proceeding to open the URL. (HINT: confirm())
●​ Upon confirmation, the URL should open in a new tab, and a success message should be displayed.

Attach the JavaScript Function to the Button:

●​ Use the onclick event to link the function to the button click.

You might also like