Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Javascript help

New Here ,
Mar 12, 2010 Mar 12, 2010

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.

TOPICS
Extensions

Views

440
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 15, 2010 Mar 15, 2010

Copy link to clipboard

Copied

LATEST

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?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines