Use a public map service like this:
And yes you can use it in JS API or I would not have suggested it.
Sample of how to use Query and QueryTask with a mouse click:
You would need to use a map service that represents land and query that map service to see if the clicked point intersects if the returned features are greater than 0 then you are on land.
Thank you so much. I will have a look at these references and services.
Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.
Retrieving data ...