I got some help previously on this same page, and it was really appreciated. As I was trying to implement the code on several different pages using an include file and a single file for the popup window, I got it working on all 6 affected pages. I had various debugging lines of code in the files and after taking them out the javascript no longer works. I put some back in but it still throws an error and doesn’t change the image source.
The error it is throwing is “parent.window.opener.document.getElementById(“emailIcon”) has no properties”.
Here is the calling page’s pertinent code (or contents of the included file):
<a href=”#”
onClick=”openPopWin(’emailResponseUpgrade.asp?ID=<%=rs(“cid”)%>&uID=<%=rs(“urpID”)%>&pID=<%=pID%>&pg=<%=pqs%>’, 575, 465, ‘scrollbars’, 20, 20)”>
<% If rs(“eCount”) <> 0 then %>
<img name=”emailicon” border=”0″ src=”images/emailIcon.jpg” width=”26″ height=”30″>
<% Else %>
<img name=”emailicon” border=”0″ src=”images/emailIcon2.jpg” width=”32″ height=”30″>
<% End if %>
</a>
Here is the function code in the popup window:
function changeEmailIcon()
{
alert(“Before change parent.window.opener.document.getElementById(’emailIcon’).src = ” + parent.window.opener.document.getElementById(’emailIcon’).src)
parent.window.opener.document.getElementById(’emailIcon’).src =”images/emailIcon.jpg”
// alert(“After change parent.window.opener.document.getElementById(’emailIcon’).src = ” + parent.window.opener.document.getElementById(’emailIcon’).src)
alert(“Just changed emailIcon on referring page to white”)
}
And here is the code that calls the function:
<form name=yourform action=”emailRespProc.asp?ID=<%= csID %>” method=”post”>
<textarea rows=”10″ name=”msg” cols=”57″ style=”font-family: Verdana,Arial; font-size: 10pt”></textarea></p>
<input type=”hidden” value=”<%= eID %>” name=”Email”>
<input type=”hidden” value=”<%= seID %>” name=”sEmail”>
<input type=”hidden” value=”<%= cuID %>” name=”uID”>
<input type=”hidden” value=”<%= pgID %>” name=”pgID”>
<input type=”hidden” value=”<%= pg %>” name=”pg”>
<input type=”hidden” value=”<%= orBy %>” name=”orID”>
<p>
<input type=”submit” value=”Send Email Message” onClick=”changeEmailIcon()”>
</form>
The last alert() in the function code is all that works due to the error mentioned above.
I would be most grateful – again – if someone could look over this code and give me an idea why the object has no properties and what I can do to access the properties that I’m not doing now.
Thanks,