0

I'm creating a web push notification setup on my website, and honestly I've never had this issue javascript before that I'm encountering. Essentially what is happening here is that when javascript should be invoking the called method, nothing is happening. Not even a try-catch is catching an error.

test.html

Here is where I'm attempting to call the method from. If you will notice, in the <head> tag I referenced the js file that has the method.

<html>
    <head>
        <script src="notify.js"></script>
    </head>
    <body>
        <script type="text/javscript">
            document.write("Test #1");
            try {
                document.write(sendUnsent()); 
                document.write("Test #2");
            } catch (error) {
                document.write(error);
            }
        </script>
    </body>
</html>

notify.js

This is where I'm attempting to call said function called sendUnsent().

function sendUnsent()
{
    return "Hello world!";
}

My question is why is this script not executing and what possible fixes are there?

apotter96
  • 137
  • 11

1 Answers1

1

You have a typo in the type of your script tag, it should be text/javascript:

<script type="text/javascript">
    document.write("Test #1");
    try {
        document.write(sendUnsent()); 
        document.write("Test #2");
    } catch (error) {
        document.write(error);
    }
</script>
Jason Aller
  • 3,391
  • 28
  • 37
  • 36
El Aoutar Hamza
  • 3,878
  • 2
  • 10
  • 19