Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #41207
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Obtaining the DOM tree for a *.htm file on a local disc? |
| Date | 2023-02-21 22:13 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <12162747.O9o76ZdvQC@PointedEars.de> (permalink) |
| References | <7cb3d7c8-74e8-49d2-ba7d-ab6df813f0c1n@googlegroups.com> |
John Stockton wrote:
> Is there a readily-available function which can be called from JavaScript
> running in a normal modern browser which, given as an argument the name
> (relative to the current directory, or maybe absolute) of an HTML file,
> will return a reference to the parsed DOM tree of the BODY of the HTML,
> including the Links, Anchors, etc. arrays?
Apparently they have even killed file:// to file:// HTTP requests in/by
Chromium 108 :-(
| Access to fetch at 'file:///ā¦' from origin 'null' has been blocked by CORS
| policy: Cross origin requests are only supported for protocol schemes:
| http, data, isolated-app, chrome-extension, chrome, https, chrome-
| untrusted.
So AFAIK it is only possible now with a local Web server where the target
file is also a resource accessible via HTTP:
fetch(httpURI).then(response => {
response.text().then(response2 => {
var doc = (new DOMParser()).parseFromString(response2, 'text/html');
/* Example */
console.log(doc.images);
});
});
(WFM.)
DOMParser is available since the time of Firefox 1 (2006).
If you do not have fetch(), you should write one using XMLHttpRequest.
<https://developer.mozilla.org/en-US/docs/Web/API/DOMParser>
<https://developer.mozilla.org/en-US/docs/Web/API/fetch>
<https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest>
<http://PointedEars.de/es-matrix/#javascript>
--
PointedEars
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2
Please do not cc me. /Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Obtaining the DOM tree for a *.htm file on a local disc? John Stockton <dr.j.r.stockton@gmail.com> - 2023-02-16 15:25 -0800
Re: Obtaining the DOM tree for a *.htm file on a local disc? Dr.Kral@nyc.rr.com - 2023-02-16 19:46 -0500
Re: Obtaining the DOM tree for a *.htm file on a local disc? Ezimene nimi Teine nimi <yyyyyeeeee00000@writeme.com> - 2023-03-06 03:17 -0800
Re: Obtaining the DOM tree for a *.htm file on a local disc? Jon Ribbens <jon+usenet@unequivocal.eu> - 2023-02-17 01:06 +0000
Re: Obtaining the DOM tree for a *.htm file on a local disc? JJ <jj4public@outlook.com> - 2023-02-17 08:34 +0700
Re: Obtaining the DOM tree for a *.htm file on a local disc? "Jšššš¤ ššš£š" <noneya.invalid@gmail.com> - 2023-02-17 15:13 +0000
Re: Obtaining the DOM tree for a *.htm file on a local disc? K <techfan55555@hotmail.com> - 2023-03-11 01:59 -0800
Re: Obtaining the DOM tree for a *.htm file on a local disc? Arno Welzel <usenet@arnowelzel.de> - 2023-02-19 00:33 +0100
Re: Obtaining the DOM tree for a *.htm file on a local disc? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2023-02-21 22:13 +0100
Re: Obtaining the DOM tree for a *.htm file on a local disc? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2023-02-21 22:15 +0100
Re: Obtaining the DOM tree for a *.htm file on a local disc? Arno Welzel <usenet@arnowelzel.de> - 2023-03-09 03:06 +0100
Re: Obtaining the DOM tree for a *.htm file on a local disc? John Stockton <dr.j.r.stockton@gmail.com> - 2023-03-04 13:36 -0800
Re: Obtaining the DOM tree for a *.htm file on a local disc? JJ <jj4public@outlook.com> - 2023-03-05 23:05 +0700
Re: Obtaining the DOM tree for a *.htm file on a local disc? John Stockton <dr.j.r.stockton@gmail.com> - 2023-03-05 15:26 -0800
csiph-web