/    Sign up×
Community /Pin to ProfileBookmark

Object has no properties ??

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,

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ZeroKilledDec 27.2007 — as far i can see you has not defined the id attribute on image tag. don't confuse name attribute with id attribute which they are different:
[code=html]<img id='emailicon' ... />[/code]
Copy linkTweet thisAlerts:
@loydcampbellauthorDec 27.2007 — Thank you ZeroKilled. That was what I was missing. It works by adding the id='emailicon'. I really appreciate your assistance.
×

Success!

Help @loydcampbell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...