Component transfer from one html file to another using Javascript.

Is it possible that using querySelector i get one component say a card from one html and insert it into another html page.(no click function the second page auto fetches it from the other page) I think I can use querySelectorAll to get the component. But dont know how to insert it or if it's possible. If there is any video or you can show just a single code.
18 Replies
Monimolimnion
Monimolimnion•3y ago
to what end?
Malik
MalikOP•3y ago
what do you mean? I'm new so I dont understand the term. it's just static html css
Monimolimnion
Monimolimnion•3y ago
it's not a term, it's English 🙂 i mean, what are you trying to achieve?
Malik
MalikOP•3y ago
Like say I've a <div class="card"></div> on page1.html using javascript can I like fetch it and use it on the page2.html
Monimolimnion
Monimolimnion•3y ago
not really
Malik
MalikOP•3y ago
ok Thank You tho.
Monimolimnion
Monimolimnion•3y ago
you would have the card as a separate file
Malik
MalikOP•3y ago
🙂 can you send me blog or vid regarding that
Monimolimnion
Monimolimnion•3y ago
if you're looking to do things like that, you should look into using a framework like Astro which is built from the ground up to use components
Malik
MalikOP•3y ago
ok. One more question if you dont mind.
Monimolimnion
Monimolimnion•3y ago
sure
Malik
MalikOP•3y ago
I tried using astro. but the css doesn't seem to work. it got imported and shows up in dist folder https://discord.com/channels/436251713830125568/1094765808170836138
Monimolimnion
Monimolimnion•3y ago
probably worth asking in the astro server oh, it won't let me link to it
Malik
MalikOP•3y ago
ok. Thank you for the help.
Monimolimnion
Monimolimnion•3y ago
Astro
Astro
Astro is an all-in-one framework for building fast websites faster. Grab content from anywhere, deploy everywhere, and show the web what you've got.
Monimolimnion
Monimolimnion•3y ago
discord link top right
Jochem
Jochem•3y ago
yeah, sorry about that, we were getting a bunch of spambots posting discord links. Currently monitoring how the new filter rule works, and how many spam links it blocks versus legitimate uses
Monimolimnion
Monimolimnion•3y ago
Np, that's fair enough Discord needs some kind of 'blue checkmark' system really

Did you find this page helpful?