Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetAttribute not working

Status
Not open for further replies.

joelwenzel

Programmer
Jun 28, 2002
448
I have this code and it is not working. Anyone know why? I'm using ASP.NET and it shows getAttribute as having the following arguments...getAttribute(strAttributeName, [lFlags], AttributeValue) which doesn't make any sense to me. Anyway, here is the code I was trying to use.


<script type="text/javascript" language="JavaScript">
alert( document.getElementById('bgImage1').getAttribute('id'));
</script>

...

<div id="bgImage1" style="position: absolute;width:1000px;height:432px;left:0px;top:50px;">
<img src="Images/bliss top.bmp" alt="" width="100%" height="100%" />
</div>
 
getAttribute might be an ASP function, but I don't think it's JavaScript.

To get the id (once you have the element), just ask for it by name!

document.getElementById('bgImage1').[red]id[/red]

Dave

P.S., if you're using the ID to get the element, though, you probably don't need to get it again! :)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
I realize that about the id. i was doing an example to demonstrat that I can achieve some element. In the example, it should display 'bgImage1'.

Anyway, I think getAttribute is a javascript function. The msdn list it as part of DOM


Maybe it is only in internet explorer though?

What I really need is a way to change the entire style string. I can't do document.GetElementByID('idname').style.[property] = value; because I need to adjust the filter property which isn't listed.
 
Problem solved. I made the stupid mistakeof using the id of a server element rather then the client id. 'bgImage1' was run at the server.
 
'glad you figured it out.

Thanks for pointing out the getAttribute function. I've never used it before. I probably won't, still, but it's good to know it's an option!

Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top