|
Post by ǻñî§ђ™ on Sept 4, 2011 23:08:22 GMT
OK, chrome is really getting on my nerves. I first had a problem with innerHTML begin null but I tried to instead hide the elements if you where either logged in or viewing as a guest. But now I get the error message cannot read property style of null. I googled it and came up with nothing of relevance. Here is the code:
document.write('<table width="92%" align="center"><tr><td width="100%"><div style="float:left;" id="left_s"><span id="log1"><font color="#ffffff">Logged in as, <a href="?action=viewprofile">'+pb_displayname+'</a> - <a href="?action=logout">Logout</a> - <a href="?board=shop">Shop</a> - </font></span><span id="log2"><font color="#ffffff">You are not logged in!</font></span></div><div style="float:right;" id="right_s"><span id="log3"><font color="#ffffff"><a href="?action=modifyprofile&user='+username+'">Edit Profile</a> - <a href="?action=pm">Inbox ('+newpm+')</a></font></span><span id="log4"><font color="#ffffff"><a href="?action=login">Login</a> - <a href="?action=register">Register</a></font></span></div></td></tr></table>'); if(pb_username == "Guest") { zD.$("log1").style.display = 'none'; zD.$("log3").style.display = 'none'; } else { zD.$("log2").style.display = 'none'; zD.$("log4").style.display = 'none'; }
zd.$ is a function i set up to return an id. Someone please help! And sorry if this is the wrong board.
|
|
Jordan
Elite Poster
[M:5000]
Posts: 286
|
Post by Jordan on Sept 4, 2011 23:50:08 GMT
Can you post all of the code, or link to where it's in use? My guess is the reference returned by your function is null, so you are basically doing null.style.display = "none";
|
|
|
Post by ǻñî§ђ™ on Sept 4, 2011 23:56:02 GMT
I'm gonna PM you the links because the project is secret.
|
|
Cam
Administrator
[M:5000]
Posts: 6,381
|
Post by Cam on Sept 5, 2011 0:48:34 GMT
It's it the same project which I know about? I could try look at it.
|
|
Jordan
Elite Poster
[M:5000]
Posts: 286
|
Post by Jordan on Sept 5, 2011 0:56:22 GMT
The problems appears to be that the HTML written by the document.write() method hasn't yet been converted into objects in the DOM, so when he tries to retrieve the element's with the given ID's, they can't be found because they don't yet exist. That's my guess, so he'll just need to take a different approach such as putting that HTML directly in his header and then calling the zD.$() function on them since they will definitely exist within in the DOM that way.
|
|