In safari, it seems like the focus is given to the context menu when right-clicking, so the context menu receives the mouseup event rather than the P element. As for a solution, you can detect the mouse button to prevent it to behave on the right click. Right click events are messy unless you want to handle a custom context menu.
If you want the mouseup event to work in safari when fired with a right click, you will need to disable the context menu by adding this attribute to the P element:
oncontextmenu="return false">
It is also possible to detect if the left click fired the event (which is usually the button you want to handle):
function mouse_handler(event) {
var evt=window.event||event;
var button = evt.which || evt.button;
if (button == 1) { // if left mouse button
// handle the event
}
}
In the example from w3schools, it would lead to something like this:
function myFunction(elmnt,clr,event)
{
var evt=window.event||event;
var button = evt.which || evt.button;
if (button == 1) { // if left mouse button
elmnt.style.color=clr;
}
}
Then passing the event in the function call:
<p onmousedown="myFunction(this,'red',event)" onmouseup="myFunction(this,'green',event)">