Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

HTML & CSS need help in understanding on why is my code not calling the Javascript button.

HTML:
<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML MAP TAGS
    </title>
        <style>
            h1 {
               background-color: rgb(202, 164, 114);
               color: #C0C0C0;
               text-align: center;
            }
        </style>
    </head>
    
    <body>
        <h1> Image Maps</h1>
        <p> Click on the computer, the phone, or the cup of coffee to go to a new page and read more about the topic:</p>
        <img src="workplace.jpg" alt="workplace computer" usemap="#workmap">

        <map name="workmap">
        <area shape="rect" coords="33,44,271,346" alt="computer" href="https://en.wikipedia.org/wiki/Computer" target="_blank">
        <area shape="rect" coords="287,172,334,246" alt="phone" href="https://en.wikipedia.org/wiki/Mobile_phone" target="_blank">
        <area shape="circle" coords="341,293,50" alt="coffee" href="https://en.wikipedia.org/wiki/Coffee" target="_blank">

        <h1 style="background-color:#062e69; color:#fff; text-align:center;"> Food items on a table</h1>

        <p style="color:#062e69;"> Click on the crossiant to go to the page containing in-depth information about the crossiant </p>

        <img src="frenchfood.jpg" alt="crossiant" usemap="#crossiant">

        <map name="crossiant">
            <area shape="poly" coords="144,122,187,122,204,164,207,203,183,280,129,340,87,356,53,351,38,325,44,241,126,134" href="https://en.wikipedia.org/wiki/Croissant" onclick="my Function()">
        </map>

        <script>
        function myFunction() {
             alert("You clicked on the crossiant!");
        }
        </script>
    </body>
</html>
 
Last edited by a moderator:
Solution
Your function name is - "myFunction()" but on your html area you have separated the function name like - "my Function()". Remove the space between the function name and it will work.
Your function name is - "myFunction()" but on your html area you have separated the function name like - "my Function()". Remove the space between the function name and it will work.
 
Solution

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom