SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Omaha, NE
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Refreshing a window from another window

    Hi...

    Here is my issue.

    I have a page (Eventlist.cfm) that opens another page (updateevent.cfm). UpdateEvent.cfm then calls another page (deleteevent.cfm) that deletes an event then closes the delete window and the UpdateEvent.cfm window. Sometime in there I need force the original page (Eventlist.cfm) to refresh after the delete.

    The code that calls the delete page is:
    Code:
    function DeleteEvent(eventform) 
    	{ 
    	  textvalue = "Are you sure you want to delete this event?";
    	  if (confirm(textvalue))
    	  {
    	  	eventform.deletevalue.value = 1;
    		eventform.updatevalue.value = 0;
    		urlvalue = "deleteeventwindow.cfm?eventid=" + eventform.eventid.value;
    	  	window.open(urlvalue, "DeleteEventWindow", 
    	            "status=1,toolbar=0,location=1,menu=0,scrollbars=no,width=500,height=300"); 
    	  } 
    	}

    The Delete page looks like the following

    Code:
    <cfquery name="GetEvent" datasource="#CalDSN#">
    		Delete From ewga_ca_events
    		Where eventID = #eventid# 
    </cfquery>
    
    <html>
    <head>
    	<title>Untitled</title>
    	<script language="javascript">
    <!--
    	function CloseWindow() 
    	  {
    	    window.opener.close();
    	  	window.close();
    	  }
    	
    	//-->
    	</script>
    </head>
    
    <body onload="CloseWindow();">
    
    
    
    </body>
    </html>

    So from the delete page how can force the original page to refresh?

    Thanks
    "Oh, you hate your job? Why didn't you say so? There's a support group for that.
    It's called EVERYBODY, and they meet at the bar."

    --Drew Carey

  2. #2
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey there!

    A couple of ideas on this one:

    1) (not as accurate) Set a time out to refresh the original page after X seconds. (Figure out how long your delete and update functions take, then add about a second for padding). This way when they click the button or whatever to update and delete, it starts a timer that refreshes the page. By the time it refreshes, the other actions should be complete.

    Code:
    <script language="javascript" type="text/javascript">
        function doStuff() {
           window.open([url-to-update-event-here], 'mywin, '');
           setTimeout('location.reload()', 3000);
        }
    </script>
    
    <input type="button" onClick="doStuff();">
    2) Don't close the update window from the delete window. Call the update window, do your stuff, then open the delete window. When the delete window is done, have it call a function on the update window that reloads the opener and closes the update window. (Make sense?)

    In the update window:
    Code:
    ... do CF stuff/update...
    
    <script language="javascript" type="text/javascript">
        function doStuff() {
            window.open([url-to-delete-stuff], 'mywin', '');
        }
        function afterDelete() {
            window.opener.location.reload();
            window.close();
        }
    </script>
    In the delete window:
    Code:
    .... do CF stuff/delete...
    <script language="javascript" type="text/javascript">
        function doStuff() {
            window.opener.afterDelete();
            window.close()
        }
    </script>
    Note that to call functions on an opener, I think you need to use [window.opener.document.functionCall()] for it to work in Netscape... Play around with it and see.

    3) Don't open two new windows. Call your updates, then pass any needed parameters on to your delete page and do your deletes. Use new windows very sparingly.

    Hope this helps, have fun!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •