1

I'm trying to get all the innerHTML of my web form, here's what I'm doing:

I need to be able to do this for parent of the window. So to begin, using var = dialog I get the window.parent as shown below:

function PrintForm() {

   var dialog = window.parent.wdwBHForm;

}

Now I'm trying to use dialog (parent of window) to get all innerHTML, because my end goal is to be able to print it.

var html = dialog.contentDocument.documentElement.innerHTML

I've tried this line above, but it doesn't work.

I also have infragistics control that I need to get innerHTML for - I hope I'd be able to do the same.

Any idea?

Koosh
  • 876
  • 13
  • 26

1 Answers1

1

May be you can do that in the following way:

function PrintForm() {
   var innerHtml = window.document.documentElement.innerHTML;
   // If you want to access the parent window
   // var innerHtml = window.parent.document.documentElement.innerHTML;
   console.log(innerHtml);
}
<form name="myForm" id="myForm">
  UserName : <input type="text" name="userName"> 
</form>
<button onclick="PrintForm()">Show InnerHTML</button>
Mamun
  • 66,969
  • 9
  • 47
  • 59
  • @mason, but I think there is no `parent` on `window` object. – Mamun Dec 29 '17 at 15:17
  • @mason, since OP didn't provide any `HTML`, I did it with a single window object....thanks for the point though. – Mamun Dec 29 '17 at 15:24
  • @mason, I answered with `May be` so that OP can get some idea to solve his problem even if he fails to make us understand his context fully. – Mamun Dec 29 '17 at 15:32
  • @mason, I have seen lot of answers like that and I feel there is nothing wrong with that. – Mamun Dec 29 '17 at 15:37
  • I appreciate the help with this @Mamun – Koosh Dec 29 '17 at 15:38
  • I also appreciate @mason your comments – Koosh Dec 29 '17 at 15:38
  • @mason, then I have to change the `HTML` as well. What I can do is mention this for child-parent window situation, which eventually I did...thanks again for helping me to update the answer. – Mamun Dec 29 '17 at 16:03