https://docterhelth.blogspot.com/
The `openLinksAutomatically()` function finds all the anchor tags (`<a>`) on the page and sets their `target` attribute to `'_blank'`, which opens the links in a new tab or window.
The `loadContentAndOpenLinks()` function is called when the page loads (`onload` event). In this example, we have a sample content variable with an HTML string containing a link. You can replace this sample content with your actual dynamic content fetched from an external source.
The `contentElement.innerHTML = content;` line updates the HTML content of a specific element on your page, in this case, the `<div>` with the ID "content". You can change this ID to match the ID of the element where you want to display the dynamically loaded content.
Finally, the `openLinksAutomatically()` function is called to find the links within the dynamically loaded content and open them in new tabs or windows.
Please note that in order to load the content dynamically from an external source, you would need to implement the appropriate mechanism to fetch the content using JavaScript's `fetch` API or other similar methods. The example provided assumes a static content variable for simplicity.
إرسال تعليق