in reply to How to glue JavaScript and DOM

The perl code returns an array of hash references whereas the value that comes here is the length of the array.
What perl code? And the javascript code you've shown does nothing like that (or at least, it shouldn't).

Also please tell me how to get the handle of the calling object.. eg
I don't understand what you're asking. And the example doesn't help.

How to get the handle of meta in perl so as to return the appropriate value..
Again, I have no idea what you're asking.

Replies are listed 'Best First'.
Re^2: How to glue JavaScript and DOM
by monkster (Sexton) on Feb 26, 2008 at 14:03 UTC
    1. var metas = document.getElementsByTagName('meta') is supposed to return an array containin the lines that has the meta tag.. since this is not supported by SpiderMonkey per se, i wrote a perl code somethin like
    function_get("getElementsByTagName", sub { #use HTML::TagParser, my @array = $p->getElementsByTagName('@_); #$p must point to # the html file containin the page from which meta tags are # to be taken return @array; });
    So ideally i must get an array, but I m not..2. handle of the callin object: eg: javascript has lines like write
    metas[i].getAttribute('name'); //metas is the array obtained from the +above snippet<code>
    So to write a perl function similar to the one that i wrote for getElementsByTagName as shown above, i need to get a handle for this metas array object in perl.. How do i get this is my question..I guess I have it more clear now.. Please tell me if it's still hazy
      1. var metas = document.getElementsByTagName('meta') is supposed to return an array containin the lines that has the meta tag.
      document.getElementsByTagName is supposed to return a NodeList, not a plain array of Nodes.

      function_get("getElementsByTagName", sub { #use HTML::TagParser, my @array = $p->getElementsByTagName('@_); #$p must point to # the html file containin the page from which meta tags are # to be taken return @array; });
      That defines a global getElementsByTagName function. You want set it as a property of the document object instead. That way, you should get the document object as the first argument when called.

      update: in fact, function_get() does not exist in JavaScript::SpiderMonkey. There is a function_set, but that's a method. Have you actually read the documentation?

      So to write a perl function similar to the one that i wrote for getElementsByTagName as shown above, i need to get a handle for this metas array object in perl.. How do i get this is my question..
      Again, metas is not an array. Also, metas[i].getAttribute refers to the getAttribute property of whatever is element i in metas, so you'd better make sure that that property exists. As far as I can tell, your code does nothing of the kind.

        oops, typographical error.. meant function_set only..
        getElementsByTagName returns NodeList in both javascript and perl(method of HTML::DOM and other similar modules), however the formats are differents. can u please suggest me how to make the NodeList of Perl compatible with that of javascript???