0

I am trying to figure out why this JS alert is not working. The function of the alert is to validate if the data been selected before.

 <script type="text/javascript">
        alert("This location been chosen.\n Please choose another location.");
        history.back();
 </script>

However when I try to check the error, I'm turning on the ColdFusion debug, the js alert runs smoothly.

Leigh
  • 28,765
  • 10
  • 55
  • 103
syida
  • 17
  • 5
  • [**works for me**](http://jsfiddle.net/SaX4E/) – qwertymk Jul 17 '12 at 02:34
  • it will work only after i'm turning on the cf debug – syida Jul 17 '12 at 02:37
  • can you paste the generated code when CF debug is turned off? to say.. http://pastebin.com if big – scunliffe Jul 17 '12 at 02:43
  • it will display error page. however when i had comment the js run smotthly – syida Jul 17 '12 at 04:01
  • @syida I just noticed your comment above. Do you mean that when you comment out your error handling (like it is shown in your comment) your JavaScript alert runs, but when you leave the above error handling uncommented (== active) the JavaScript alert does not run? Do you understand what the commented out code does? – Germann Arlington Aug 22 '12 at 11:05

2 Answers2

1

Unless window.alert has been redefined it will work as long as you pass it a value that is a string (or converts to a string).

I'd suspect that either the script tag is not being output in your generated source or that there is a JavaScript error elsewhere that is causing all code after it to not parse.

scunliffe
  • 62,582
  • 25
  • 126
  • 161
0

Most likely your generated JavaScripts are not valid - check JavaScript warnings in your browser.

Germann Arlington
  • 3,315
  • 2
  • 17
  • 19