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 [Link] If not, the function should prepend https:// to the
URL. (HINT: [Link]("[Link] checks whether a string starts with "[Link]
● 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.