Link to home
Start Free TrialLog in
Avatar of Destiny Amana
Destiny AmanaFlag for Nigeria

asked on

Javascript Error in Onclose Handler

I got this script of Dynamic Drive and have been trying to customise the script.

This is the original


<script type="text/javascript">

var agreewin=dhtmlmodal.open("agreebox", "iframe", "surveyinfo.asp", "UBA Survey", "width=590px,height=250px,center=1,resize=1,scrolling=0", "recal")

agreewin.onclose=function(){ //Define custom code to run when window is closed
      var theform=this.contentDoc.getElementById("eula") //Access form with id="eula" inside iframe
      var yesbox=theform.eulabox[0] //Access the first radio button within form
      var nobox=theform.eulabox[1] //Access the second radio button within form
      if (yesbox.checked==true)
            alert("You are now being redirected to our online survey\nThank you for taking time out to do this survey")
            
            else if (nobox.checked==true)
            //alert("You didn't agree to the terms")
            return true //Allow closing of window in both cases            
}
</script>

And this is the line that I have added "window.location.href="./polls/default.asp""

I want this to riderect and open a new windows but the script generates an error message before redirecting and it redirects to the parent window.

<script type="text/javascript">

var agreewin=dhtmlmodal.open("agreebox", "iframe", "surveyinfo.asp", "UBA Survey", "width=590px,height=250px,center=1,resize=1,scrolling=0", "recal")

agreewin.onclose=function(){ //Define custom code to run when window is closed
      var theform=this.contentDoc.getElementById("eula") //Access form with id="eula" inside iframe
      var yesbox=theform.eulabox[0] //Access the first radio button within form
      var nobox=theform.eulabox[1] //Access the second radio button within form
      if (yesbox.checked==true)
            alert("You are now being redirected to our online survey\nThank you for taking time out to do this survey")
            
            else if (nobox.checked==true)
            //alert("You didn't agree to the terms")
            return true //Allow closing of window in both cases
      window.location.href="./polls/default.asp"
            
}

</script>

Could someone help me out here ?
ASKER CERTIFIED SOLUTION
Avatar of neeraj523
neeraj523
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Destiny Amana

ASKER

Could you also add a cookie so that on the default page, the script does not load again.
yes... u can do that..