Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: window.opener.event.srcElement


Message #1 by danielsj@h... on Thu, 11 Apr 2002 17:35:27
> I need a reference to ...window.opener.event.srcElement

I've figured this out.  You can't reference window.opener.event.srcElement 
becasue there is no event currently bubling (in IE).  An event handler CAN 
reference event.srcElement for the duration of an event handler, but 
functions that aren't event handlers CAN't do this because there is no 
current event.

Instead I created and initialised a property for the parent window object 
(outside any event handling code):

window.elementClicked = null

Then set the value of the property inside the appropriate event handler:

document.onmousedown(){
  window.elementClicked = event.srcElement
  // do other stuff
}

So now a window created using window.open can reference a srcElement on 
the parent page.  For example, to display the tagName property of the 
clicked element on the parent page:

  alert(window.opener.elementClicked.tagName)



  Return to Index