Issue closing a dialog that contains an iframe.... from within the iframe

Issue closing a dialog that contains an iframe.... from within the iframe

I have a function which takes a url and opens a jquery dialog. I've used it in a few places and it works fine where the dialog doesn't need to be closed programatically.

  1. function ModalFramedDialog(winTitle, url, winWidth, winHeight) {
      $
    ('<div id="myAdhocIframeDialog" style="overflow:hidden;"><iframe id="myAdhocIframeWindow" frameborder="0" width="100%" height="100%" src="' + url + '" /></div>').dialog({
        title
    : winTitle,
        autoOpen
    : true,
        width
    : winWidth,
        height
    : winHeight,
        resizable
    : false,
        autoResize
    : true,
        modal
    : true
     
    }).width(winWidth - 30).height(winHeight - 30);
    }

I want to be able to close the dialog from within the iframe on the onclick event of an anchor.

  1.   <a href="#" onclick="$('#myAdhocIframeDialog', window.parent.document).dialog('close');">
       
    <img src="../Content/Images/AdminImages/Category.gif" alt="Category" />
        Category Management
     

    </a>

I can get a handle on the div that's the dialog...

  1. onclick="alert($('#myAdhocIframeDialog', window.parent.document).html());"

and i can hide the div (which just leaves the dialog window title visible)...

  1. onclick="$('#myAdhocIframeDialog', window.parent.document).hide();"

But trying to actually close the dialog results in nothing.... no errror, no closed dialog.

Can anyone advise a way forward without completely changing how i'm creating the dialog??