I'm coding a shopping cart in HTML, PHP, and JS. I have an onclick
function that deletes a cookie and refreshes the page, which removes the item from the shopping cart. This works in Chrome and the cookie is deleted. I have the same code in Firefox, but it doesn't work: the cookie isn't deleted in Firefox. Here's the element with the onclick
attribute:
echo '<button class="button" onclick="removeCart' . $x . '()">Remove from Cart</button>';
Here's the function:
echo '<script>';
echo 'function removeCart' . $x . '() {';
echo 'document.cookie = "' . $itemsSpaced[$x] . '= ; expires=Thu, 01 Jan 1970 00:00:00 UTC";';
echo ' location.reload(true);';
echo '}';
echo '</script>';
Why does this work in Chrome, but not Firefox?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…