this post was submitted on 24 Oct 2023
2 points (100.0% liked)

HTML

309 readers
1 users here now

founded 1 year ago
MODERATORS
 

Hi,

I would like to display an element (div) of another web page, hosted on a owned sub domain..

I was planning to use iframe, but it seem that iframe only allow to grab the entire page... any ideas ?

Thanks.

top 5 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 1 year ago

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/HTML_in_XMLHttpRequest

Grab the HTML. Slice up the DOM to get the div. Add to the page.

Probably want more than just the div. Might run into cross origin issues.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

@[email protected] & @[email protected]

Thank you for your input !

I've finally ~~used~~ been forced to use https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API and DOMParser().parseFromString()

I say forced, because so far it's only that Prehistoric JS available for the front-end, HOPEFULLY there is some coming kick-ass technology to get rid of JS --> https://brython.info ❤️

[–] [email protected] 1 points 1 year ago (1 children)

Never used brythom but I'm aware of it, what's the pros?

[–] [email protected] 1 points 8 months ago

You can interact with the HTML DOM with Python !!!!!

[–] [email protected] 1 points 1 year ago

Instead of using JavaScript to grab it from that other page, it might be worth it to make that snippet of html its own file and then call it, both in the original page and the page you're making. It sounds like this is feasible too if you have ownership over that other subdomain. I know they used to use this technique a lot back in the old days of just html, so it'd probs work for you.