0

I'm writing an application that will run on an embedded old browser (I mean really old browser. User agent: ANTGalio/2.1.19.12.2.1.19.12.020.3.0.00; vxWorks-6.3).

This browser don't support the function querySelectorAll or querySelector. I would like to know some alternative for those functions which will do the same job.

If there is no function which will do this, where can I get the code of the querySelector function, so I can try to write it by hand with JavaScript.

freginold
  • 3,946
  • 3
  • 13
  • 28
Vitor Villar
  • 1,855
  • 18
  • 35
  • 2
    What *does* the browser support? Which browser are you asking about specifically? – Bergi Jul 26 '17 at 13:23
  • 1
    https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills#dom--events. Alternatively, is jQuery an option? – Bergi Jul 26 '17 at 13:24
  • 3
    [Here's the same question](https://stackoverflow.com/q/28194786/1048572) about IE6 – Bergi Jul 26 '17 at 13:25
  • To be precise, this is the user agent from the browser: `ANTGalio/2.1.19.12.2.1.19.12.020.3.0.00; vxWorks-6.3` – Vitor Villar Jul 26 '17 at 13:31

1 Answers1

0

If there is not function which do this.

There is … it's querySelector. That's why it was created. Before it existed we had to use other methods.

Where can I get the code of the querySelector function?

There will be a custom implementation for each browser, usually written in C++, so probably not a whole lot of use to you.

Sizzle provides a selector library that does a similar job. It is used by jQuery as a fallback for older browsers. It is 2277 lines lines long: Not something you want to try recreating from scratch.

You could also look at using features like getElementById, getElementByClassName, parentNode and so on instead of expressing things in terms of selectors.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I know about `querySelector` but I'm running in a browser which don't have those functions natively. That's why I'm asking for alternatives. And I tried Sizzle, it didn't work too. – Vitor Villar Jul 26 '17 at 13:33
  • @VitorVillar — My point was that querySelector was created to fulfil a need. If there was a drop in replacement that already existed in browsers it wouldn't have needed to be created in the first place. – Quentin Jul 26 '17 at 13:39
  • @VitorVillar What did not work when you tried Sizzle? – Bergi Jul 26 '17 at 15:58