Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

extract html from a file

Featured Replies

Hi

 

My website is in a constant state of work-in-progress. It works, it's pretty and easily accessible. However, I want to add some javascript enhancement to the site so that it runs as seamlessly as possible for users with the correct software.

 

All my pages are just that: separate pages. I know I can selectively show and hide elements using javascript, and that I can import an html fragment file into the page.

 

I don't want to do either of those: I want to open an html file, get one element, import it and display it so that it appears that only the new content is provided (not the entire new page).

 

Eg:

 

<html>
<div class="dontneed">
 <!-- Don't need this content -->
</div>
<div class="need">
 <!-- Need to extract this for my page -->
</div>
</html>

 

Can that be done?

I would go with PHP - purely as the work would be done on the server, and any clients don't need Javascript running.

  • Author

Thanks for the reply.

 

Since I'm intending to progressively enhance my site, I think the job will need to be done by asynchronous request. That means javascript. So I'll hijack the link, do the javascript and the new page appears to replace the current one.

 

People without javascript will just get the link to a new page.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.