From: Dr J R Stockton on 24 Apr 2010 13:30 In comp.lang.javascript message <hqqom3$jlf$1(a)news.eternal- september.org>, Thu, 22 Apr 2010 17:12:47, Garrett Smith <dhtmlkitchen(a)gmail.com> posted: >Dr J R Stockton wrote: >> In comp.lang.javascript message <4bc4f77a$0$286$14726298(a)news.sunsite.dk >>> , Tue, 13 Apr 2010 23:00:03, FAQ server <javascript(a)dotinternet.be> >> posted: >>> --- >>> FAQ Topic - How do I modify the content of the current >>> page? >>> --- >>> >>> Using the non-standard but widely implemented ` innerHTML ` property: >>> ` <div id="anID">Some Content</div> ` with script: >>> >>> document.getElementById("anID").innerHTML = >>> "Some <em>new</em> Content"; >> ISTM that, where the element is a PRE, and the assigned string >>contains >> whitespace, then for IE8 each block of whitespace is treated as a single >> space, and for other browsers the whitespace is happily preserved. >> That may be worth mentioning. >> > >There are other deviations between implementations and discrenpencies >with the Draft Standard HTML 5. > ><http://www.whatwg.org/specs/web-apps/current-work/multipage/apis-in- >html-documents.html#innerhtml> > >Says there document.innerHTML is available but it is not available in >the latest of Opera or Firefox. It is present in the latest ordinary releases of those; I don't use betas & suchlike. Removal would be a mistake. >HTML 5 also specifies behavior that diverges greatly from what any >version of Internet Explorer does. The FAQ should concern itself predominantly with what browsers actually do, not with what a possible future standard might say. >>> If the new content is only text and does not need to replace >>>existing HTML, >>> it is more efficient to modify the ` data ` property of a text node. >>> >>> document.getElementById("anID").firstChild.data = "Some new Text"; >> Using that preserves the whitespace, but does not treat a >>A<sub>J</sub> >> as HTML - which in this case is worse. Code is at >> <URL:http://www.merlyn.demon.co.uk/js-randm.htm#GP>, subsection "New >> Test", function ResolD. The function contains Wryt which uses >> innerHTML. >> > >The paragraph in the FAQ begins with "If the new content is only text." >The specification is linked as well. Yes, but not helpful. Remember that thread topics expand. There is a clear difference in behaviour here between IE & the rest, and I was hoping to be offered a convenient workround. If innerHTML does go, the FAQ will need to offer a compatible replacement for element.innerHTML = StringOfHTML ; ..firstChild.data is inadequate. >> Function ResolD is new, superseding ResolA ResolB ResolC. On the >> reasonable assumption that the only stuck bits are trailing zeroes, it >> determines the number of significant bits in the value of Math.random() >> as a function of the position of the leading "1" bit when the value is >> represented in fixed-point binary. >> MS IE 8 1 53, 2 54, 3 54, 4 54, 5 54, 6 54, ... >> Firefox 3.0.19 1 53, 2 53, 3 53, 4 53, 5 53, 6 53, ... >> Opera 10.10 1 53, 2 53, 3 53, 4 53, 5 53, 6 53, ... >> Safari 4.0.5 1 30, 2 30, 3 30, 4 30, 5 30, 6 30, ... >> Chrome 4.1 1 30, 2 30, 3 30, 4 30, 5 30, 6 30, ... >> > >OK, but what's that got to do with this FAQ Entry? The page was cited, and the new result form might be of interest or amusing. Lasse, do you still have an Opera with the range bug discussed here in 2003? -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 7. Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links. I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt; free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/> unsupported.
From: Dr J R Stockton on 26 Apr 2010 13:40 In comp.lang.javascript message <hr0qk7$205$1(a)news.eternal- september.org>, Sun, 25 Apr 2010 00:22:44, Garrett Smith <dhtmlkitchen(a)gmail.com> posted: >Can you mention the problem that you think should be addressed here? Is >it whitespace? What are you getting at? I did. Using MS IE, go to <URL:http://www.merlyn.demon.co.uk/js-randm.htm#GP>, then down a bit to heading "New Test - Test Resolution", then on to a blue form. Set the window to the design width, such that the code box occupies the full width (more or less) press the "1" button, and observe the wider yellow box in the form showing ONE line of text overflowing to the right. After a while, press the "0" button in the form. Now repeat exactly with a reputable browser; note that whitespace is now rendered as one would evidently wish. You have seen the first few numbers in that box before. That box is called "Hits"; read the code above backwards, and you will soon see how the string S which is written to it by innerHTML in Wryt is composed to represent array AD neatly. In Chrome and Safari, the second wide yellow box may receive contents within an hour or so; in IE, Firefox, Opera, it will take around a millennium. ASIDE : via revised sig below, one can reach a version of MiniTrue which works properly in Windows XP in interactive mode, which is good. -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 7. Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links. MiniTrue is good for viewing/searching/altering files, at a DOS / CMD prompt; free, DOS/Win/UNIX, see via <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.
From: Dr J R Stockton on 28 Apr 2010 11:51 In comp.lang.javascript message <hr5m5p$hph$1(a)news.eternal- september.org>, Mon, 26 Apr 2010 20:37:27, Garrett Smith <dhtmlkitchen(a)gmail.com> posted: >Dr J R Stockton wrote: >> In comp.lang.javascript message <hr0qk7$205$1(a)news.eternal- >> september.org>, Sun, 25 Apr 2010 00:22:44, Garrett Smith >> <dhtmlkitchen(a)gmail.com> posted: >> >>> Can you mention the problem that you think should be addressed here? >>>Is >>> it whitespace? What are you getting at? >> I did. Using MS IE, go to >> <URL:http://www.merlyn.demon.co.uk/js-randm.htm#GP>, then down a bit to >> heading "New Test - Test Resolution", then on to a blue form. Set the >> window to the design width, such that the code box occupies the full >> width (more or less) press the "1" button, and observe the wider yellow >> box in the form showing ONE line of text overflowing to the right. >> After a while, press the "0" button in the form. >> > >I am unfamiliar with the term "design width". What is that? Just as its natural meaning in the Queen's English. The "such that" above tells you how to do it even if the meaning eludes you. If you happen to have a window 5000 px wide with default font set to 4 pt, then the problem will probably not appear even in IE. If you have a window 640 px wide with default font 36 pt, the desired appearance will not appear even in non-IE. My page design is on the whole flexible; but degrades if bent too brutally. >http://www.google.com/search?hl=en&client=firefox- >a&hs=Bsw&rls=org.mozilla%3Aen-US%3Aofficial&ie=UTF-8&oe=UTF-8&q=define% >3A%22design+width%22&aq=f&aqi=&aql=&oq=&gs_rfai= > >Says: > >| The width specification that a sidewalk or trail was intended to meet, >| usually set by building codes or agency guidelines. > >Can't be that. Not *exactly* that, but essentially similar. >> Now repeat exactly with a reputable browser; note that whitespace is now >> rendered as one would evidently wish. >> > >Can provide a short summary, followed by a brief description and an >example. Tell us what you thought the expected outcome should be and >then show what really happened, and in which browsers and versions. > >I have no idea what you are expecting You were told that in the article which introduced the matter to this thread, "Date: 22 April 2010 14:24:45". -- (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME. Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links. Proper <= 4-line sig. separator as above, a line exactly "-- " (RFCs 5536/7) Do not Mail News to me. Before a reply, quote with ">" or "> " (RFCs 5536/7)
From: Dr J R Stockton on 6 May 2010 13:02 In comp.lang.javascript message <hrqto9$dv5$1(a)news.eternal- september.org>, Tue, 4 May 2010 21:55:34, Garrett Smith <dhtmlkitchen(a)gmail.com> posted: >Garrett Smith wrote: >> Dr J R Stockton wrote: >>> In comp.lang.javascript message <hrgeuf$ac2$1(a)news.eternal- >>> september.org>, Fri, 30 Apr 2010 22:41:32, Garrett Smith >>> <dhtmlkitchen(a)gmail.com> posted: >>>> Dr J R Stockton wrote: > >[...] > >> I'll provide a proposal later. > >| How do I modify the content of the current page? >| >| Using the non-standard but widely implemented `innerHTML` property: >| <div id="anID">Some Content</div> with script: >| >| document.getElementById("anID").innerHTML = >| "Some <em>new</em> Content"; >| >| Where "anID" is the (unique on the HTML page) id attribute value of >| the element to modify. It would be better to have an earlier FAQ section on the various ways of obtaining a reference to an element, and to put instead of that reference.innerHTML = "Some <em>new</em> Content"; Commonly, though, an ID is used. The above code should not be used multiple times, but should be made a function : function Wryt(ID, S) { document.getElementById(ID).innerHTML = S } -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME. Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links; Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc. No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
From: Dr J R Stockton on 9 May 2010 14:27 In comp.lang.javascript message <hrvu7q$7cr$1(a)news.eternal- september.org>, Thu, 6 May 2010 22:29:11, David Mark <dmark.cinsoft(a)gmail.com> posted: >> The above code should not be used >> multiple times, but should be made a function : >> >> function Wryt(ID, S) { document.getElementById(ID).innerHTML = S } >> > >I fail to see how that should be a rule. In fact, it is often a bad >idea to exit an execution context amid multiple DOM updates as it >triggers costly (and sometimes ugly) re-flows. Kindle explain how replacing something like document.getElementById("A").innerHTML = S1 .... document.getElementById("B").innerHTML = S2 .... document.getElementBy1d("C").innerHTML = S3 .... document.getElementById("D").innerHTML = S4 .... document.getElementById("E").innerHTML = S5 with something like Wryt("A", S1) .... Wryt("B", S2) .... Wryt("C", S3) .... Wryt("D", S4) .... Wryt("E", S5) add reflow costs. It aids clarity, and reduces the chance of the sort of typo that may not have been noticed above. If, as must often be the case, S1 replaces text of the same length, there will be no reflow; if of similar length, often no more than a line reflow. And in any case, current machines are so fast that reflow, if required, will usually take negligible time. -- (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3 6.20 ; WinXP. Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links. PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm> My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: "INSERT INTO Next: Are Unsecured Debt Consolidation Loans the Right Solution? |