Loading ...
Sorry, an error occurred while loading the content.

Re: [OLmws] Close popup on clicking of link

Expand Messages
  • Foteos Macrides
    If the DHTML popup content is a complete HTML file imported via iframe, cf.: http://www.macridesweb.com/oltest/IFRAME.html and
    Message 1 of 2 , Oct 18, 2006
    • 0 Attachment
      If the DHTML popup content is a complete HTML file imported via iframe, cf.:
       
      and
       
      and you wish to close the popup when the user clicks on a link within the imported file that invokes a new window or tab, then the link should use onclick to make a cClick call in the parent.  In your example (appended), you would use:
       
       <a
         href="new_document.html"
         onclick="if (parent != self) parent.cClick(); return true;"
         target="_blank">4</a>
       
      The test for whether the document has a parent avoids a potential javascript error if the document is viewed directly rather than via the popup.  It returns true so that the link's href will be acted upon.
       
      If (as you presently are doing) the DHTML popup instead uses object with type="text/html" to import the HTML file, cf:
       
      you run into the problem of inconsistent implementations of object across browsers.  For example, Firefox uses essentially the same code for its implementation of object in that case as for iframe, and so the two elements work equivalently for this HTML markup and javascript.  They also both work as intended with Opera (and probably Safari, but I haven't checked to be sure).  But unfortunately, IE has a weird implementation of object which does not register the parent document as parent, and so this HTML markup and javascript fail.
       
      If there is some reason why you cannot use iframe instead of object to import the HTML file, then a "sorta" workaround for IE's weird implementation of object is to include MOUSEOFF for the popup in the parent document.  The popup will not close when the user clicks on a link in the imported HTML file that opens a new window or tab, but will close when that new window or tab is closed or minimized and the cursor returns to the parent document.  You can keep the onclick markup for the browsers which do handle object as expected, so that the popup closes immediately for them.  If you want to make the MOUSEOFF specific to IE, use:
       
      . . . , (OLie4 && !OLopr)?MOUSEOFF:DONOTHING, . . . 
       
      in the overlib command.
       
      Fote
      --
       
      ----- Original Message -----
      From: ssmattson
      Sent: Wednesday, October 18, 2006 2:40 PM
      Subject: [OLmws] Close popup on clicking of link

      Hi Fote,

      I'm a JS novice and having a little trouble getting the desired behavior.  I have a link that invokes an overlib popup that loads an external html file using the object method.  In that file are links which open yet another document.  What I would like to do is have the popup close when a user clicks on a link which opens a new document, it would be like how the calendar would work if clicking on a date actually opened up a new browser window (document) but still closed itself.

      Here's the code for the popup:
      . . . 
      <li>
       <a
         href="javascript:void(0);"
        onclick="overlib('&lt;object data=\'object_popup.html\' '
         +'id=\'ID\' width=\'370\' height=\'140\' '
         +'type=\'text/html\'&gt;&lt;/object&gt;', STICKY,
         TEXTPADDING, 0, CAPTIONPADDING, 1,
         CAPTION, 'Document Caption', BORDER, 0, WRAP,
         SCROLL, CLOSECLICK, CLOSETEXT, closeimg,
         EXCLUSIVE, HIDESELECTBOXES ); return false;"
       >Open popup</a>
      </li>
      . . . 

      And for the link that should close the popup and open a new document:
      . . . 
      <td>
       <a
         href="new_document.html"
         target="_blank">4</a>
      </td>
      . . . 

      I would appreciate any help with this.  Thanks Fote.

      S.
    • Sean mattson
      Thanks Fote, As usual, your response has been immensely helpful. Regards, S Foteos Macrides wrote: If the DHTML popup content is a
      Message 2 of 2 , Oct 19, 2006
      • 0 Attachment
        Thanks Fote,
        As usual, your response has been immensely helpful.
         
        Regards,
        S

        Foteos Macrides <fote@...> wrote:
        If the DHTML popup content is a complete HTML file imported via iframe, cf.:
         
        and
         
        and you wish to close the popup when the user clicks on a link within the imported file that invokes a new window or tab, then the link should use onclick to make a cClick call in the parent.  In your example (appended), you would use:
         
         <a
           href="new_document.html"
           onclick="if (parent != self) parent.cClick(); return true;"
           target="_blank">4</a>
         
        The test for whether the document has a parent avoids a potential javascript error if the document is viewed directly rather than via the popup.  It returns true so that the link's href will be acted upon.
         
        If (as you presently are doing) the DHTML popup instead uses object with type="text/html" to import the HTML file, cf:
         
        you run into the problem of inconsistent implementations of object across browsers.  For example, Firefox uses essentially the same code for its implementation of object in that case as for iframe, and so the two elements work equivalently for this HTML markup and javascript.  They also both work as intended with Opera (and probably Safari, but I haven't checked to be sure).  But unfortunately, IE has a weird implementation of object which does not register the parent document as parent, and so this HTML markup and javascript fail.
         
        If there is some reason why you cannot use iframe instead of object to import the HTML file, then a "sorta" workaround for IE's weird implementation of object is to include MOUSEOFF for the popup in the parent document.  The popup will not close when the user clicks on a link in the imported HTML file that opens a new window or tab, but will close when that new window or tab is closed or minimized and the cursor returns to the parent document.  You can keep the onclick markup for the browsers which do handle object as expected, so that the popup closes immediately for them.  If you want to make the MOUSEOFF specific to IE, use:
         
        . . . , (OLie4 && !OLopr)?MOUSEOFF:DONOTHING, . . . 
         
        in the overlib command.
         
        Fote
        --
         
        ----- Original Message -----
        From: ssmattson
        Sent: Wednesday, October 18, 2006 2:40 PM
        Subject: [OLmws] Close popup on clicking of link

        Hi Fote,

        I'm a JS novice and having a little trouble getting the desired behavior.  I have a link that invokes an overlib popup that loads an external html file using the object method.  In that file are links which open yet another document.  What I would like to do is have the popup close when a user clicks on a link which opens a new document, it would be like how the calendar would work if clicking on a date actually opened up a new browser window (document) but still closed itself.

        Here's the code for the popup:
        . . . 
        <li>
         <a
           href="javascript:void(0);"
          onclick="overlib('&lt;object data=\'object_popup.html\' '
           +'id=\'ID\' width=\'370\' height=\'140\' '
           +'type=\'text/html\'&gt;&lt;/object&gt;', STICKY,
           TEXTPADDING, 0, CAPTIONPADDING, 1,
           CAPTION, 'Document Caption', BORDER, 0, WRAP,
           SCROLL, CLOSECLICK, CLOSETEXT, closeimg,
           EXCLUSIVE, HIDESELECTBOXES ); return false;"
         >Open popup</a>
        </li>
        . . . 

        And for the link that should close the popup and open a new document:
        . . . 
        <td>
         <a
           href="new_document.html"
           target="_blank">4</a>
        </td>
        . . . 

        I would appreciate any help with this.  Thanks Fote.

        S.


        Do you Yahoo!?
        Get on board. You're invited to try the new Yahoo! Mail.

      Your message has been successfully submitted and would be delivered to recipients shortly.