Copy link to clipboard
Copied
Hi,
I am including some Javascript in my Dreamweaver file an everything is being executed just fine except for the bit of code that changes the URL of the main page (document.location). Can you please explain why this one specific line is not working? It works for other people, according to some examples. Is there another way to make my page go to another url?
Here is my code:
<script type="text/javascript"> <!-- function confirmation() { var answer = confirm("Leave?") if (answer){ alert("Bye bye!") window.location = "http://www.google.com/"; //this does not work!! } else{ alert("Thanks for sticking around!") } }
The alert lines work, so function is working, but when it comes to going to the url, no dice. I have tried redirecting to another file on my server, also does not work. I have tried other commands, and they dotn work either. what is the appropriate code to use?
Thank you.
Copy link to clipboard
Copied
I copied the code to a blank page and tested the confirmation() function onload. It worked fine in IE8, Firefox 3.6 and Chrome 4.0....
I would maybe check that you are hitting OK in the original confirm dialogue box, and maybe add all the missing ; to the end of all the command lines.
what browser were you using?