Onclick JS function call, returns "Can't find variable" only in Safari Console

Viewed 6046

So I have a very simple JS function written that works like the following.

There is a button that has the following code:

<button type="submit" class="large button" onclick="addCart(76,95,73,96);">
    <i class="icon-shopping-cart"></i> Add to Cart
</button>

Now when that is clicked there is a very simple function added to the page below that looks like the following:

<script type="text/javascript">
    function addCart(pid, pattr, pval, pscent = 0) {
    ...
    }
</script>

This works perfectly in Chrome, Firefox, Chrome for Mobile, Safari for Mobile.

But this does not seem to work on Safari on Mac. Instead I get the following error:

ReferenceError: Can't find variable: addCart

I cannot figure out why. It's hard for me to add a listener because there are 7 buttons and a wide arrange of variables that are being sent, and I'd rather send that like I'm currently doing.

3 Answers
Related