Solved

Javascript Error in Onclose Handler

Posted on 2008-06-12
3
654 Views
Last Modified: 2013-11-19
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 ?
0
Comment
Question by:souldj
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
neeraj523 earned 500 total points
ID: 21768583
should be like this

this should open default.asp page in a new window before redirecting..
<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")
		window.open('./polls/default.asp','pop')
	}
    //alert("You didn't agree to the terms")
    return true //Allow closing of window in both cases
	}
</script>

Open in new window

0
 
LVL 1

Author Comment

by:souldj
ID: 21770905
Could you also add a cookie so that on the default page, the script does not load again.
0
 
LVL 22

Expert Comment

by:neeraj523
ID: 21771358
yes... u can do that..
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery GMAP3 Hierarchy 1 28
Index on a Table 6 15
Jquery 2 12
how can i get the string decoded ? 2 14
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question