Re: OT: need javascript/DOM help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bassel Safadi wrote:
On Sat, Jun 21, 2008 at 12:09 AM, Mike Wright <mike.wright@xxxxxxxxxxxxxx>
wrote:


Are there any javascript/DOM gurus out there who can tell me why the html
page below finds the <p> tag and the <div> tag but ignores the <a> tag.

Below is the html being tested.

=====================

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head><title>Javascript DOM Experiments</title></head>
<body>

<p   id='m'></p>

<a   id='a'></a>
<p   id='p'></p>
<div id='v'></div>

<script type='text/javascript'><!--//
var d = document;
var m = d.getElementById('m');
var a = d.getElementById('a');
var p = d.getElementById('p');
var v = d.getElementById('v');
var b = '<br />';
m.innerHTML = a+b+p+b+v+b;
//--></script>

</body>
</html>


will it's simple ,
what do you want to get from the getElementById('')?
I mean if you're trying to know what kind of element is it, just to process
it in some how, then you will not get a result from just using the
getElemntByid thing for example:

d.getElementById('p');
will return in Firefox: [object HTMLParagraphElement]
in IE Mac: [object P]

why don't you just specify what you want to get back from it let's say you
may use:

 var a = d.getElementById('a').innerText;
by the way adding href="" to the anchor tag will let  var a =
d.getElementById('a'); return the href it self, if you still need an output
that looks like:
[object HTMLanchorElement]

tell me and will find a work around for you...

Thanks for your generous offer, Bassel.

I need the node so I can use "nextSibling".

What I'm trying to accomplish is to "display:none" or "display:block" the following element whenever the <a> is onclicked.

As you pointed out "document.getElementById()" returns not the id, but the href. (That really puzzles me and differs from the O'Reilly books on Javascript and Dynamic HTML).

Is this a known bug? If it is I will have to wrap my tags in such a way that I can find the other node relative to it some other way.

If you have ideas I'm eager and open eared :)

Mike Wright :m)

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux