0

So are nothing I have found on the web addresses this unique circumstance so I'll ask now.

I have an empty DIV which is working as a "container" to hold and display an 'external' HTML document.

<div id="page-content-wrapper" style="border: medium solid #000000; height:660px">
      <!--Loaded content goes here-->
</div>

In the Sidebar of this page is a list of documents (HTML docs) from which the user may pick.
There is Javascript to load the selected 'external' HTML document into the DIV (page-content-wrapper).
The SidebarItemClick method code for that is:

function MenuClick(doc) {
   var Tutorial = doc;
   var DisplayObj = "<object id='ThisObj' type='text/html' data='" + Tutorial + "' style='min-width:100%; min-height: 101%; overflow: hidden'></object>";
   document.getElementById("page-content-wrapper").innerHTML = DisplayObj;
}

That works fine. The document is displayed nicely on the webpage.

NOTE: As can be seen in the code, I am not using iFrame for a variety of reasons - mostly because my boss said "NO IFRAME".

NOTE2: Even when I can physically see the 'external' HTML document being displayed on the webpage within the DIV (page-content-wrapper) - when I examine the Page Source at that moment in time, the text of the 'external' HTML document does not appear - although the

Now I want to put together some Javascript to enable the user to Search for text within that 'external' HTML document and scroll (if necessary) the 'found' text to a visible part of the webpage.

As I said at the beginning, nothing I have found so far on the web seems to address this situation so I hope someone has a workable approach.

Your advice/suggestions will be greatly appreciated.

Thanks

Dhugalmac
  • 554
  • 10
  • 20
  • The "external html" becomes part of the DOM when it is loaded into the `div` and can be treated like any other DOM structure from then on. – Mouser Oct 20 '17 at 21:51
  • Also we need to see a live example to help you further. – Mouser Oct 20 '17 at 21:52
  • 1
    Since you say the document is displayed nicely on the webpage, the normal browser search should be sufficient to search and locate text, no? – Reg Edit Oct 20 '17 at 21:54
  • "when I examine the Page Source at that moment in time, the text of the 'external' HTML document does not appear" That's because the page _source_ doesn't have it, but the DOM does. Any solution you find that involves using JavaScript to search text will work, because that text is in the DOM. – Nathan Hinchey Oct 20 '17 at 22:05
  • @RegEdit The new html is not a part of the DOM, its dynamically added, this is why you can't bind it to an event handler. – Nabil Ali Oct 20 '17 at 22:07
  • Since this website will be for 'general' users I cannot depend on them being knowledgeable on how to use Browser Searches. So instead I have put a Search textbox and button on the form. Clicking on the Search button fires off the Javascript function to do the search. Unfortunately, while the JS function can find the DIV (page-content-wrapper) it cannot find document and/or the text that it is displaying. How can I find text within that 'external' document? – Dhugalmac Oct 23 '17 at 14:10
  • If I need to show more code, what specifically more needs to be shown? I have shown the DIV (page-content-wrapper) code and the JS function of how it gets loaded. I can also show the JS function code I am attempting to use for the Search, but since it isn't working is it of any value? – Dhugalmac Oct 23 '17 at 14:12

0 Answers0