Changing link attributes from a popup window

Discussion in 'JavaScript' started by Krakatoa, Mar 8, 2006.

  1. #1
    I have a problem changing onlick, onmouseover and onmouseout attributes of a link in a page from a popup window opened by this page.

    In the popup window I have this code:

    
    element = window.opener.document.getElementById('link_id');
    
    element.onclick = function () {
      pop_width  = 340;
      pop_height = 450;
      hspace = ( screen.width - pop_width ) / 2;
      vspace = ( screen.height - pop_height ) / 2;
      parameters = 'resizable=no,scrollbars=no,width=' + pop_width + ',height=' + pop_height + ',left=' + hspace + ',top=' + vspace;
      window.opener.open ( 'page.htm'', 'title', parameters );
    }
    
    element.onmouseover = function () {
      window.opener.status = 'a_string';
      return true;
    }
    
    element.onmouseout = function () {
      window.opener.status = '';
      return true;
    }
    
    Code (markup):
    The problem is that this code only works if the popup window remains open.
    If I close it, it stops working. What can I do???
    :confused:
     
    Krakatoa, Mar 8, 2006 IP
  2. Jowan Pasco

    Jowan Pasco Peon

    Messages:
    38
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should put this code into the parent window. Once your popup is closed, this code is no longer active.
     
    Jowan Pasco, Mar 8, 2006 IP
  3. Krakatoa

    Krakatoa Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Already done and it works!
    Thank you anyway!!!
    :D
     
    Krakatoa, Mar 8, 2006 IP