{"id":56711,"date":"2022-10-09T03:01:39","date_gmt":"2022-10-08T17:01:39","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=56711"},"modified":"2022-10-02T16:53:13","modified_gmt":"2022-10-02T06:53:13","slug":"html-link-contenteditable-url-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-link-contenteditable-url-primer-tutorial\/","title":{"rendered":"HTML Link Contenteditable URL Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/alink_contenteditable.jpg\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"HTML Link Contenteditable URL Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/alink_contenteditable.jpg\" title=\"HTML Link Contenteditable URL Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">HTML Link Contenteditable URL Primer Tutorial<\/p><\/div>\n<p>Around here we&#8217;re keen on the <a target=_blank title='Global contenteditable attribute information from W3schools' href='https:\/\/www.w3schools.com\/tags\/att_global_contenteditable.asp'>contenteditable<\/a>=true HTML global attribute, but had never applied it to any HTML &#8220;a&#8221; links until we did it when we presented <a target=_blank title='Image and Text PDF Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/image-and-text-pdf-primer-tutorial\/'>Image and Text PDF Primer Tutorial<\/a> &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='Image and Text PDF Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/image-and-text-pdf-primer-tutorial\/#acelink'>Specifically, here, with an \"a\" link whose \"href\" attribute equals its \"innerHTML\" contenteditable wording<\/a><br \/>\n<\/code><\/p>\n<p> &#8230; the delay in applying being that we had to reconcile two ways in which a click or tap by the user can mean either &#8230;<\/p>\n<ol>\n<li>click to navigate to the &#8220;a&#8221; link&#8217;s &#8220;href&#8221; attribute URL &#8230; or &#8230;<\/li>\n<li>click to gain focus for the contenteditable user controlled keyboard means of changing the &#8220;a&#8221; link&#8217;s &#8220;innerHTML&#8221; property<\/li>\n<\/ol>\n<p> &#8230; and so we needed to use lots of inline Javascript HTML event logic as per &#8230;<\/p>\n<p><code><br \/>\n&lt;a target=_blank style='padding: 3 3 3 3;' title='Can change URL or wait 8 seconds for navigation to occur' id=\"acelink\" data-ce='' onclick=\"if (this.getAttribute('data-ce').length == 0) {  this.style.textDecoration='none';  this.style.backgroundColor='#e0e0e0';  setTimeout(function(){ if (document.getElementById('acelink').getAttribute('data-ce').length == 0) { document.getElementById('acelink').setAttribute('data-ce','n');  document.getElementById('acelink').setAttribute('contenteditable', !document.getElementById('acelink').getAttribute('contenteditable')); document.getElementById('acelink').click();  } },8000); }\" onkeydown=\"this.setAttribute('data-ce','y'); this.title='Will navigate to your new URL.';\" href=\"https:\/\/www.rjmprogramming.com.au\/pdfimageplustext.php?pdfimageplustext=y&pdfimage=moodle.jpg&pdftext1=Moodle%20Page&pdfx1=230&pdfy1=250\"  onblur=\" this.style.textDecoration='underline';  this.style.backgroundColor='white';  this.href=this.innerHTML.replace(\/\\&amp\\;\/g,'&'); this.setAttribute('contenteditable', !this.getAttribute('contenteditable')); this.click();\" contenteditable=true&gt;https:\/\/www.rjmprogramming.com.au\/pdfimageplustext.php?pdfimageplustext=y&pdfimage=moodle.jpg&pdftext1=Moodle%20Page&pdfx1=230&pdfy1=250&lt;\/a&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; to make this be possible, as you can try below &#8230;<\/p>\n<p><a target=_blank style='padding: 3 3 3 3;' title='Can change URL or wait 8 seconds for navigation to occur' id=\"acelink\" data-ce='' onclick=\"if (this.getAttribute('data-ce').length == 0) {  this.style.textDecoration='none';  this.style.backgroundColor='#e0e0e0';  setTimeout(function(){ if (document.getElementById('acelink').getAttribute('data-ce').length == 0) { document.getElementById('acelink').setAttribute('data-ce','n');  document.getElementById('acelink').setAttribute('contenteditable', !document.getElementById('acelink').getAttribute('contenteditable')); document.getElementById('acelink').click();  } },8000); }\" onkeydown=\"this.setAttribute('data-ce','y'); this.title='Will navigate to your new URL.';\" href=\"https:\/\/www.rjmprogramming.com.au\/pdfimageplustext.php?pdfimageplustext=y&#038;pdfimage=moodle.jpg&#038;pdftext1=Moodle%20Page&#038;pdfx1=230&#038;pdfy1=250\"  onblur=\" this.style.textDecoration='underline';  this.style.backgroundColor='white';  this.href=this.innerHTML.replace(\/\\&#038;amp\\;\/g,'&#038;'); this.setAttribute('contenteditable', !this.getAttribute('contenteditable')); this.click();\" contenteditable=true>https:\/\/www.rjmprogramming.com.au\/pdfimageplustext.php?pdfimageplustext=y&#038;pdfimage=moodle.jpg&#038;pdftext1=Moodle%20Page&#038;pdfx1=230&#038;pdfy1=250<\/a><\/p>\n<p>We hope this is of some interest to you!<\/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='#d56711' onclick='var dv=document.getElementById(\"d56711\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/contenteditable\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d56711' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Around here we&#8217;re keen on the contenteditable=true HTML global attribute, but had never applied it to any HTML &#8220;a&#8221; links until we did it when we presented Image and Text PDF Primer Tutorial &#8230; Specifically, here, with an &#8220;a&#8221; link &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-link-contenteditable-url-primer-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":[112,211,2442,2666,576,1525,652,1807,3220,860,861,1705,997,1319],"class_list":["post-56711","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-attribute","tag-click","tag-contenteditable","tag-href","tag-html","tag-innerhtml","tag-javascript","tag-link","tag-navigate","tag-onblur","tag-onclick","tag-onkeydown","tag-programming","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/56711"}],"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=56711"}],"version-history":[{"count":5,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/56711\/revisions"}],"predecessor-version":[{"id":56716,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/56711\/revisions\/56716"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=56711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=56711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=56711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}