List Info

Thread: Javascript statement: visible=(obj.style.display=="block"); problem in Konqueror 3.4.2




Javascript statement: visible=(obj.style.display=="block& quot;); problem in Konqueror 3.4.2
country flaguser name
United States
2007-07-09 13:06:51
I'm having trouble with a javascript program I've copied out
of a book (to 
continue my experimentation/learning).  The program works
fine in opera, but 
gives me a "Type Error -- Null Value" at the
following line (in Konqueror 
3.4.2):

visible=(obj.style.display=="block");

(In the book that I copied the program from, it didn't have
the trailing 
semicolon, but I added that and have tried it both ways.)

The lines preceding that line are:

function Toggle(e) {
  if (!document.getElementById) return;
  if (!e) var e = window.event;
  whichlink = (e.target) ? e.target.id : e.srcElement.id;
  obj=document.getElementById(whichlink+"menu");
  visible=(obj.style.display=="block");

I've done a little experimenting, trying things like:

obj.style.display="block";
obj.style.display="inline";
obj.style.display="none";
obj.style.display="0";

...but all with the same error and message.

In another trial program (which I wrote myself), I used
statements like the 
following with no problem:

<span id="H11" !--onclick show spans L1 and
H2--
onclick='document.getElementById("L11").style.disp
lay="block"; 
document.getElementById("H1121").style.display=&qu
ot;block"'>

So, then I tried a statement like the following, but ended
up with the same 
"Type Error -- Null Value":

visible=(document.getElementById(whichlink+"menu")
.style.display=="block");

Randy Kramer

___________________________________________________
This message is from the kde-linux mailing list.
Account management:  http
s://mail.kde.org/mailman/listinfo/kde-linux.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.h
tml.

Konqueror 3.4.2.: For a window.event, both target.id and srcElement.id are undefined (wa
country flaguser name
United States
2007-07-09 21:48:53
On Monday 09 July 2007 02:06 pm, Randy Kramer wrote:
> function Toggle(e) {
>   if (!document.getElementById) return;
>   if (!e) var e = window.event;
>   whichlink = (e.target) ? e.target.id :
e.srcElement.id;
>  
obj=document.getElementById(whichlink+"menu");
>   visible=(obj.style.display=="block");

I've gotten a little further.  By adding a document.write
line just before the 
whichlink line, I've found that neither e.target.id nor
e.srcElement.id are 
defined.

I guess I should mention that Toggle is called as follows:

document.getElementById("products").onclick=Toggle
;

Any hints?

Randy Kramer
___________________________________________________
This message is from the kde-linux mailing list.
Account management:  http
s://mail.kde.org/mailman/listinfo/kde-linux.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.h
tml.

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )