Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

attachEvent

Status
Not open for further replies.

rpeters74

Programmer
May 24, 2002
46
US
I am able to attach events to an image like so:


===============================================
var oOpenImg = document.all('imgOpen');
oOpenImg.attachEvent('onclick', alert);
===============================================


Once I open a new window via JavaScript, I reference the same image like so:


===============================================
var oOpenImg = top.opener.parent.frames['main'].document.all('imgOpen');
===============================================


Within the new window I am able to work with the image like so:


===============================================
oOpenImg.src = '/Images/open.gif';
oOpenImg.className = 'ActiveImage';
===============================================


What I can't seem to do is attach an event to this Image within in the new Window:


(The follow does not work)
===============================================
var oOpenImg = top.opener.parent.frames['main'].document.all('imgOpen');
oOpenImg.attachEvent('onclick', alert);
===============================================

Any insight would be appreciated.

-rp
 
interesting...well, i found if you define a function attach() on the main page, you can call it from the child window:

on the main page:
function attach() {
var oOpenImg = document.all('imgOpen');
oOpenImg.attachEvent('onclick', alert);
}

from the child window:
<input type=&quot;button&quot; value=&quot;attach&quot; onclick=&quot;top.opener.parent.frames['main'].attach();&quot; /> =========================================================
if (!succeed) try();
-jeff
 
gorgeous!!!

jemminger ... you are the man/(women?). works like a charm. I have an external javascript file included in both the opener and the window that opened. seems that the fucntion I was setting the attachEvent to was within the same window, not the opener window like you specified.

I really appreciate your help.

thanks again ...

-rp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top