innerhtml

Insert rows into table

谁说我不能喝 提交于 2019-12-08 03:28:41
问题 What is the best plain javascript way of inserting X rows into a table in IE. The table html looks like this: <table><tbody id='tb'><tr><td>1</td><td>2</td></tr></tbody></table> What I need to do, is drop the old body, and insert a new one with 1000 rows. I have my 1000 rows as a javascript string variable. The problem is that table in IE has no innerHTML function. I've seen lots of hacks to do it, but I want to see your best one. Note: using jquery or any other framework does not count. 回答1:

Deleting child nodes of a div node

。_饼干妹妹 提交于 2019-12-08 02:26:56
问题 I have following codes to remove child nodes of a div node. Are both of these codes correct? while(innerWindowContentBox.hasChildNodes()) innerWindowContentBox.removeChild(innerWindowContentBox.childNodes[0]); Other is innerWindowContentBox.innerHTML = ''; Note that the code is for a Greasemonkey script so IE support is not required. 回答1: Both bits of code will get the job done but use the DOM approach ( that is while(innerWindowContentBox.hasChildNodes() ... ). Advantages: It's quite a bit

IE9 set innerHTML of textarea with html tags

落花浮王杯 提交于 2019-12-07 13:53:09
问题 I have this field In IE9 the following line gives me the error 'SCRIPT601: Unknown runtime error ' //option 1. document.getElementById('code').innerHTML = 'some text'; The error disappears and it seems to work (assiging empty value) when I change the line to: //option 2. document.getElementById('code').innerHTML = ''; The I tried this: //option 3. document.getElementById('code').innerHTML = escape('some text'); but then the HTML gets to be escaped and thats not what I want, I want this exact

Using innerHTML to display JSON/object data in a certain div

五迷三道 提交于 2019-12-07 12:46:34
问题 I have created the following JS code. When the HTML document loads, the script displays the three location data sets properly. <html> <head> <title>Javascript Beginner</title> </head> <body> <script> pios ('a', '7886 Dublin Blvd', 'Dublin, ', 'CA ', '94568'); pios ('b', '1 Stoneridge Mall Space', 'Pleasanton, ', 'CA ', '94588'); pios ('c', '1120 Stoneridge Mall Drive', 'Pleasanton, ', 'CA ', '94566'); function pios(iID, Address, City, State, Zip) { document.body.innerHTML +='<p id='+iID+'></p

Angular 4 Output Complete HTML Syntax code in HTML as raw text

徘徊边缘 提交于 2019-12-07 11:28:39
问题 I have scoured the possible answers and none of them work. All the innerHTML and PRE tag examples are fine with code or text, but NOT with HTML. Here is EXACTLY what I want to put into a variable: <div [ngStyle]="{'display':'flex', 'flex-direction':'column', 'width': '100vw', 'height': '100vh'}"> <top-header> <a class="topHeaderItem" (click)="goToHome()">Home</a> <a class="topHeaderItem" (click)="gotoTOC()">Contents</a> </top-header> AND THAT is precisely what I want to show up on the screen

Fire a function when innerHTML of element changes?

五迷三道 提交于 2019-12-07 09:03:20
问题 I want to fire a function when the innerHTML of a div element changes. Been testing with element.addEventListener('DOMCharacterDataModified', myFunction()); but it does not seem to work properly. It fires once when the page is loaded but never again after? See example code below. Anyone have a solution to my task? Any help is greatly appreciated! The task: I have an empty div . At random it will be fed with data from an external source (that I do not have control of). Everytime when the

text vs innerHTML in JQuery

核能气质少年 提交于 2019-12-07 03:54:45
问题 I get the same result from both methods, but not sure why. Research on SO tells me this: .text() returns JUST the text of that element and all of its descendant elements, where as .innerHTML returns all of the HTML in that element. however, further research tells me this: The real issue is that text() and innerHTML operate on completely different objects. Can I get some clarification? HTML <table id="table2"> <th> Col1 </th> <th> Col2 </th> <tbody> <tr> <td id="data">456</td> </tr> </tbody> <

JavaScript. a loop with innerHTML is not updating during loop execution

徘徊边缘 提交于 2019-12-07 03:52:31
问题 I'm trying to refresh a div from Javascript at each loop and see 1, 2, 3, .... The following code works, but only displays the final result (9998). How is it possible to display all the steps? Thank you in advance. <html> <head> </head> <body> <div id="cadre" style="width=100%;height=100%;"> <input type="button" value="Executer" onclick="launch();"/> <div id="result" ></div> </div> <script type="text/javascript"> function launch(){ for (inc=0;inc<9999;inc++){ document.getElementById('result')

Self-Closing Tag Issue with document.innerHTML in Javascript

喜欢而已 提交于 2019-12-06 14:56:36
I am writing a browser plug-in for Firefox(Greasemonkey), Opera and Chrome in Javascript for a website. The issue is, when I load the document.innerHTML into a variable, <form name="foo" action="foo.php" method="get"> <td id="td">text: <input name="k" type="text" />  </td> </form> ... the original code above of the website(which I am writing the plug-in for) is converted into <form name="foo" action="foo.php" method="get"> <td id="td">text: **<input name="k" type="text">**  </td> ... this one. As you can see, the self-closing <input /> tag is not closed anymore, and the </form> tag also

Deleting child nodes of a div node

一世执手 提交于 2019-12-06 11:11:54
I have following codes to remove child nodes of a div node. Are both of these codes correct? while(innerWindowContentBox.hasChildNodes()) innerWindowContentBox.removeChild(innerWindowContentBox.childNodes[0]); Other is innerWindowContentBox.innerHTML = ''; Note that the code is for a Greasemonkey script so IE support is not required. Both bits of code will get the job done but use the DOM approach ( that is while(innerWindowContentBox.hasChildNodes() ... ). Advantages: It's quite a bit faster. See this speed comparison at jsperf.com . On the sample HTML (hundreds of nodes, each with event