|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi,
i cant make the following basic DHTML work. Porpuse is, when mouse is clicked, make some part of page visible. but nothing hapenned ! except an instant note on status bar: error on page :) where is the error ? thanks for coming helps... ps1: both 'this.name' property and id name function calling didnt work ps2: i use IE 5.0 how can i see javascript errors at IE ? as in NN6.0 when "javascript: " is written in address bar --- HTML CODE : <script type="text/javascript"> function makevisible (spanname) { spanname.style.visibility="visible" } </script> <body> <ul> <li> <a href="javascript:makevisible(this.name)" name="span_one"> html </a> <li> <a href="javascript:makevisible(span_two)" name="span_two"> jscript </a> </ul> <span id="span_one" style="visibility:hidden" > bla bla bla of html </span> <p> <span id="span_two" style="visibility:hidden" > bla bla bla of javascript </span> ----------------------------- thnx. |
|
#2
|
||||
|
||||
|
document.getElementById(spanname).style.visiblity = "visible"
?? |
|
#3
|
|||
|
|||
|
binky: it didnt work, neither
but strange, it must have run ... any other suggestion or alternative code ? |
|
#4
|
||||
|
||||
|
In IE you can double click the yellow logo that appears at the bottom left if there's an error. Or go into internet options and switch on 'allways report javascript errors' or something to that effect.
Okay, what I can gather is this: Using: document.getElementById(spanname).style.visibility = "visible" <a href="javascript: makevisible(this.name)" name="span_one"> html </a> -- will not work because IE sees the 'name' attribute as the 'id' attribute so it gets confused, stupid eh? So, using: document.getElementById(spanname).style.visibility = "visible" and: <a href="javascript: makevisible('span_two')"> jscript </a> will work, notice the quotation marks though around the parameter being passed, and the lack of the 'name' attribute. |
|
#5
|
|||
|
|||
|
Quote:
Somebody's confused (what a shock). AnthemisCretica (gotta look that up) - Any element's id or name is intended to be unique - with the exception of radio buttons, which come in groups. If you name/id more than one element the same, the browser puts the elements in an array - since it can't store them by the same name separately. When it goes looking for the object by name/id, it finds - an array object! Not what you wanted. And: use *ids*. That's what document.getElementById() returns - a reference to an id'd element. Names are ignored. Other than form elements, the id is poised to become the standard of identifying HTML elements. blinky got the rest right: pass the id as a string (in quotes) and plug it in (at the function end) into the document.getElementById() method; once you've got that object reference, you've got the element, and you can do with it whatever's supported in scripting. |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > DHTML, visibility, etc |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|