Index: modules/overlay/overlay-parent.js
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay-parent.js,v
retrieving revision 1.13
diff -u -r1.13 overlay-parent.js
--- modules/overlay/overlay-parent.js	6 Jan 2010 15:23:32 -0000	1.13
+++ modules/overlay/overlay-parent.js	6 Jan 2010 16:48:54 -0000
@@ -210,7 +210,7 @@
     if (!self.isLoading) {
       // As the iframe is being removed we need to remove all load handlers, not
       // just the ones namespaced with overlay-event.
-      self.$iframe.unbind('load');
+      self.$iframe.unbind('load load.overlay-event');
       self.destroy();
     }
 
@@ -674,7 +678,7 @@
 
   var href = $target.attr('href');
   // Only continue if link has an href attribute.
-  if (href != undefined) {
+  if (href != undefined && href != '' && href.charAt(0) != '#') {
     // Open admin links in the overlay.
     if (self.isAdminLink(href)) {
       href = self.fragmentizeLink($target.get(0));
@@ -716,6 +720,15 @@
       // Add a target attribute to the clicked link. This is being picked up by
       // the default action handler.
       if (inFrame) {
+        // When the link has a destination query parameter and that destination
+        // is an admin link we need to fragmentize it.
+        var params = $.deparam.querystring(href);
+        if (params.destination && self.isAdminLink(params.destination)) {
+          var fragmentizedDestination = $.param.fragment(self.getPath(window.location), {overlay: params.destination});
+          href = $.param.querystring(href, {destination: fragmentizedDestination});
+          $target.attr('href', href);
+        }
+
         // Make the link to be opening in the immediate parent of the frame.
         $target.attr('target', '_parent');
       }
