In most browsers (including older versions of Safari), the Javascript prompt function returns null when the user clicks \"Cancel\", and the empty s
prompt
null
I tryed and this worked for me
var location=""; var p=prompt("type your location",location ); if(p!==null) { location = p; alert("ok do query"); }