I want the source code of an HTML page (1.html
) to be used in another page (2.html
). Furthermore, I want to perform operations on it in 2.html
.
Is there a way to do this?
EDIT: 1.html
is a separate public webpage and I do not have access to make changes to its source code. I have to do whatever I need only by using 2.html
.
If you want to find all HTML elements that match a specified CSS selector (id, class names, types, attributes, values of attributes, etc), use the querySelectorAll() method. This example returns a list of all <p> elements with class="intro" .
Right-click a blank part of the web page and select Show Page Source from the pop-up menu that appears. Once the developer options are enabled, you can also press Command + option + U to view the source code.
On Firefox, you can also use the keyboard shortcut Command-U to view the source code of a webpage. On Chrome, the process is very similar. Navigate to the top menu item “View” and click on “Developer/View Source.” You can also use the keyboard shortcut Option-Command-U .
Unlike most HTML parsers which generate tree structures, HTMLString generates a string of characters each with its own set of tags. This flat structure makes it easy to manipulate ranges (for example - text selected by a user) as each character is independent and doesn't rely on a hierarchical tag structure.
To get the DOM converted to a string:
document.getElementsByTagName('html')[0].innerHTML
Question: what do you mean by "use it"? Do you need to include 1.html inside 2.html? Or do you just need to process it?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With