Answer to Question #191552 in Python for jake

Question #191552

Create a webpage that has an image that opens a page with the Wikipedia website when clicked. Refer to the sample below for clarification.

Note: When inserting the link to your image into your code, be sure to use the full URL, including https:// at the start of the URL.




1
Expert's answer
2021-05-11T05:28:13-0400
# A simple example create webpage and write local comp 
# and opening it in a browser


import webbrowser


# Important Replace the link to the picture with your own
# "https://imgur.com/a/I8rnv45" - 
html= f"""
<!DOCTYPE html>
<html lang="en">
<head>
    <title>A simple HTML document</title>
</head>
<body>
    <p>Test example<p>
    <img src="https://imgur.com/a/I8rnv45" onclick="window.open('https://www.wikipedia.org/', '_blank')">
    
</body>
</html>
"""
# file write


file_name = "example.html"
with open(file_name, "w") as file:
    file.write(html)
# open in browser
webbrowser.open(file_name)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS