View file has a js function "confirm_result()" in <head> section:
<script type="text/javascript">
function confirm_action()
{
result = confirm("Please select OK or Cancel")
if (result == true)
document.write("You selected OK.")
else
document.write("You selected Cancel.")
}
</script>
But not in Chrome 1 or Safari 3. In the latter two the confirm box
appears, then a new blank page without the "You selected..." text. Js
otherwise working fine
Has anyone else encountered this? Bug in Rails? Chrome? Safari?
View file has a js function "confirm_result()" in <head> section:
<script type="text/javascript">
function confirm_action()
{
result = confirm("Please select OK or Cancel")
if (result == true)
document.write("You selected OK.")
else
document.write("You selected Cancel.")
}
</script>
But not in Chrome 1 or Safari 3. In the latter two the confirm box
appears, then a new blank page without the "You selected..." text. Js
otherwise working fine
Has anyone else encountered this? Bug in Rails? Chrome? Safari?
Is this written in RoR? If it is the form helper has an :onsubmit
attribute that could be useed to call that JavaScript function and I
would be willing to bet that it would work then. I have had issues with
Safari and Chrome as well but not concerning forms and JavaScript
popups.
A quick search led me to this site which shows how to use the :onsubmit
attribute:
I ran into this same issue, it has nothing to do with Rails. This
looks to be an issue with the way WebKit (used by Safari and Chrome)
handles javascript and form submits. Looks like if there is a onclick
on a submit button, data from the form is not submitted when the page
is posted.