My client has a php based bulletin board application on an internal server. It is set up so that users can post to the board and delete the post at their leisure. There is a delete page that the user visits that calls a Confirm() JavaScript function to give the user a chance to stop from accidentally deleting the post. If the user confirms the action, the post is deleted. If they cancel, they are taken to the “Edit Post” page.
Just recently, the function stopped working for the client. He gets a script error in Firefox:
Message: Object expected
Line: 210
Char: 1
Code: 0
URI:*XXXXXXXXXXXXXXXXXXXXXXXXXX
I cannot seem to replicate this issue at all. The application runs just like it is supposed to on my test server (Xampp) under IE 7, 8 and 9, Chrome and Firefox. It also runs fine on my public server under the same browsers. No errors are returned and the function does what it is supposed to do.
The real head scratcher is that I uploaded a copy to a web server with a public address to have the client try. The client did not run into the JavaScript error (using the same browser and computer as before). Everything worked just like it was designed.
In case of a corrupt file, I had the client overwrite the existing application with a fresh copy (PHP and JavaScript) on the internal server with the same files that worked for him on the public server. No luck.
The client’s IT department claims that no changes have been made to the server. Other JavaScript components (JQuery UI tabs and form validation) work just fine.
Since the web server is internal and the company is concerned about security, the web server is not connected to the internet. I don’t think that this function is using JQuery. Regardless, the JQuery library (jquery-1.4.2.min.js) is stored locally instead of referencing the JQuery server so there shouldn’t be an issue with some kind of deprecated command that I was using… if it worked before, it should work now.
I am stumped. I have tried everything that I can think of to isolate the problem. Does anyone have any idea why this would be happening?
Here is my JavaScript function:
function showConfirm(target, current) {
var r=confirm("Are you sure you want to delete this item? This action cannot be undone!");
if (r == true) {
location.replace(target)
}
else {
location.replace(current);
}
}