Comments on: Insert in place without document.write http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/ News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com. Mon, 23 Nov 2009 01:39:24 -0500 http://wordpress.org/?v=2.8.4 hourly 1 By: Juan Vazquez-Abarca http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-825950 Juan Vazquez-Abarca Thu, 13 Nov 2008 21:29:12 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-825950 James, great stuff.... However i'm wondering using this option how do i call for example a CSS file for that piece of script. Thanks James, great stuff….

However i’m wondering using this option how do i call for example a CSS file for that piece of script.

Thanks

]]>
By: Anonymous http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-757513 Anonymous Tue, 08 Jul 2008 09:15:18 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-757513 page content addition function addHTML (html) { if (document.all) document.body.insertAdjacentHTML('beforeEnd', html); else if (document.createRange) { var range = document.createRange(); range.setStartAfter(document.body.lastChild); var docFrag = range.createContextualFragment(html); document.body.appendChild(docFrag); } else if (document.layers) { var l = new Layer(window.innerWidth); l.document.open(); l.document.write(html); l.document.close(); l.top = document.height; document.height += l.document.height; l.visibility = 'show'; } } <input type="button" onclick="addHTML('<b>' + new Date() + '');" value="add current date" /> </b> page content addition

function addHTML (html) {
if (document.all)
document.body.insertAdjacentHTML(’beforeEnd’, html);
else if (document.createRange) {
var range = document.createRange();
range.setStartAfter(document.body.lastChild);
var docFrag = range.createContextualFragment(html);
document.body.appendChild(docFrag);
}
else if (document.layers) {
var l = new Layer(window.innerWidth);
l.document.open();
l.document.write(html);
l.document.close();
l.top = document.height;
document.height += l.document.height;
l.visibility = ’show’;
}
}

<input type=”button”
onclick=”addHTML(’‘ + new Date() + ”);”
value=”add current date”
/>

]]>
By: Forexman http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-732372 Forexman Sun, 25 May 2008 09:37:36 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-732372 Hi. This is really interesting post. Thank You! I have just subscribed to Your rss! Best regards Hi. This is really interesting post. Thank You! I have just subscribed to Your rss!

Best regards

]]>
By: Anonymous http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-636710 Anonymous Fri, 15 Feb 2008 19:11:06 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-636710 @above: nodeName.setAttribute('for','text') @above: nodeName.setAttribute(’for’,'text’)

]]>
By: Anonymous http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-607993 Anonymous Sun, 20 Jan 2008 20:44:32 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-607993 yeah, i have to go figure out how to apply class and for attributes... guessing theres a namespace problem, i hope there is a way around. yeah, i have to go figure out how to apply class and for attributes… guessing theres a namespace problem, i hope there is a way around.

]]>
By: Anonymous http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-313019 Anonymous Sat, 21 Jul 2007 02:41:25 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-313019 This is great, but if my text is HTML, it doesn't render. How would you apply a css class to the new text? This is great, but if my text is HTML, it doesn’t render.

How would you apply a css class to the new text?

]]>
By: Ara Pehlivanian http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-312356 Ara Pehlivanian Fri, 20 Jul 2007 13:13:49 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-312356 I do it a bit differently because an ID isn't legal in a script tag. Also, when using 3rd party scripts, you get into trouble when they have multiple document.write()s per provider. (http://arapehlivanian.com/2006/05/12/documentwrite-fix-for-real-xhtml/) I do it a bit differently because an ID isn’t legal in a script tag. Also, when using 3rd party scripts, you get into trouble when they have multiple document.write()s per provider. (http://arapehlivanian.com/2006/05/12/documentwrite-fix-for-real-xhtml/)

]]>
By: andrew.k http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-306766 andrew.k Mon, 16 Jul 2007 01:28:35 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-306766 We never had these problems with ASCII. :P EOF We never had these problems with ASCII. :P

EOF

]]>
By: brothercake http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-306737 brothercake Mon, 16 Jul 2007 00:51:14 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-306737 XHTML in IE is just HTML4 with extra slashes - sure. But in decent browsers it's XML. And guess what - it's <em>the same markup</em>. XHTML works fine; as a transitional stage from SGML-style markup that's needlessly complex to parse and error-correct, to XML-style markup that's simple and easy to parse; and as the XML itself. XHTML in IE is just HTML4 with extra slashes – sure.

But in decent browsers it’s XML. And guess what – it’s the same markup.

XHTML works fine; as a transitional stage from SGML-style markup that’s needlessly complex to parse and error-correct, to XML-style markup that’s simple and easy to parse; and as the XML itself.

]]>
By: Etnu http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/comment-page-1/#comment-305709 Etnu Sun, 15 Jul 2007 08:38:10 +0000 http://www.sitepoint.com/blogs/2007/07/11/insert-in-place-without-documentwrite/#comment-305709 Better yet -- stop wasting your time with the effectively dead technology that is xhtml. It was an interesting idea, but lets face it -- without IE support, you're going to be serving html4 anyway. HTML5 will be supported before xhtml 1.0 is. Better yet — stop wasting your time with the effectively dead technology that is xhtml. It was an interesting idea, but lets face it — without IE support, you’re going to be serving html4 anyway. HTML5 will be supported before xhtml 1.0 is.

]]>