{"id":72462,"date":"2026-03-29T03:01:00","date_gmt":"2026-03-28T17:01:00","guid":{"rendered":"https:\/\/www.rjmprogramming.com.au\/ITblog\/?p=72462"},"modified":"2026-03-30T11:48:00","modified_gmt":"2026-03-30T01:48:00","slug":"using-document-writeln-onpaste-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/using-document-writeln-onpaste-tutorial\/","title":{"rendered":"Using Document Writeln Onpaste Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/using_writeln.html\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Using Document Writeln Onpaste Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/using_writeln.gif\" title=\"Using Document Writeln Onpaste Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Using Document Writeln Onpaste Tutorial<\/p><\/div>\n<p>Regarding yesterday&#8217;s <a title='Using Document Writeln Primer Tutorial' href='#udwpt'>Using Document Writeln Primer Tutorial<\/a> you might wonder &#8230;<\/p>\n<blockquote><p>\nWhy involve either\/both textarea and div (contenteditable=true) elements as &#8220;containers&#8221; of content?\n<\/p><\/blockquote>\n<p>Well, with yesterday&#8217;s starting <i>onblur<\/i> (just) event gambit, it&#8217;s a very pertinent question, but, today, we introduce <i>onpaste<\/i> event work, and involving this event with the <i>div<\/i> element can have it distinguishing itself, able to accept graphical (eg. image) content.  For example, the user can have their cursor placed into the <i>div<\/i> element and have been in an image editor having Edit-&gt;Select All<sup>ed<\/sup> and Edit-&gt;Copy<sup>ed<\/sup> graphical content, then that can be Edit-&gt;Paste<sup>d<\/sup> into the <i>div<\/i> as graphical content.<\/p>\n<p>As you might imagine, this opens a Pandora&#8217;s Box of possibilities regarding image sizing, but we apply inline CSS styling &#8230;<\/p>\n<p><code><br \/>\n style='object-fit:contain;width:100%;height:100%;'<br \/>\n<\/code><\/p>\n<p> &#8230; to the <i>img<\/i> data URI<sup>ed<\/sup> element within the <i>div<\/i> element that happens when graphical content is pasted into it, so that the graphical data is unlikely to spill too far outside the <i>div<\/i> bounds, assuming only one image is pasted, that is.<\/p>\n<p>So feel free to try <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/using_writeln.html-GETME\" rel=\"noopener\">a changed<\/a> <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/using_writeln.html-GETME\" rel=\"noopener\">using_writeln.html<\/a> first draft <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/using_writeln.html\" rel=\"noopener\">Using (Document) Writeln<\/a> web application for you to try yourself.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=\"_blank\" href='\/\/www.rjmprogramming.com.au\/ITblog\/using-document-writeln-onpaste-tutorial\/' rel=\"noopener\">Using Document Writeln Onpaste Tutorial<\/a>.<\/p-->\n<hr>\n<p id='udwpt'>Previous relevant <a target=\"_blank\" title='Using Document Writeln Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/using-document-writeln-primer-tutorial\/' rel=\"noopener\">Using Document Writeln Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/using_writeln.html\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Using Document Writeln Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/using_writeln.jpg\" title=\"Using Document Writeln Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Using Document Writeln Primer Tutorial<\/p><\/div>\n<p>The other day we stumbled on some advice leading us to use &#8230;<\/p>\n<p><code><br \/>\ndocument.<a target=\"_blank\" href='https:\/\/www.w3schools.com\/jsref\/met_doc_writeln.asp' rel=\"noopener\">writeln<\/a>([html-content]);<br \/>\n<\/code><\/p>\n<p> &#8230; rather than our usual &#8220;go to&#8221; &#8230;<\/p>\n<p><code><br \/>\ndocument.<a target=\"_blank\" href='https:\/\/www.w3schools.com\/jsref\/met_doc_write.asp' rel=\"noopener\">write<\/a>([html-content]);<br \/>\n<\/code><\/p>\n<p>And so we wrote a &#8220;proof of concept&#8221; <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/using_writeln.html_GETME\" rel=\"noopener\">using_writeln.html<\/a> first draft <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/using_writeln.html\" rel=\"noopener\">Using (Document) Writeln<\/a> web application for you to try yourself.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d71711' onclick='var dv=document.getElementById(\"d71711\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/privacy\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d71711' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d72462' onclick='var dv=document.getElementById(\"d72462\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/onpaste\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d72462' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Regarding yesterday&#8217;s Using Document Writeln Primer Tutorial you might wonder &#8230; Why involve either\/both textarea and div (contenteditable=true) elements as &#8220;containers&#8221; of content? Well, with yesterday&#8217;s starting onblur (just) event gambit, it&#8217;s a very pertinent question, but, today, we introduce &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/using-document-writeln-onpaste-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[349,352,5446,576,652,4267,997,1986,1319],"class_list":["post-72462","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-document","tag-document-write","tag-document-writeln","tag-html","tag-javascript","tag-onpaste","tag-programming","tag-proof-of-concept","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/72462"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=72462"}],"version-history":[{"count":5,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/72462\/revisions"}],"predecessor-version":[{"id":72468,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/72462\/revisions\/72468"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=72462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=72462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=72462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}