Friday, August 21, 2020
One Click to Auto Select Code from Blockquote in Blogger
One Click to Auto Select Code from Blockquote in Blogger Blogger tutorial based site specially those who share codes in their Blog then must use blockquote. Generally main feature of blockquote is displaying the widget code within tag. We use different stylish blockquote in our site but often user has to select the whole code block top to bottom for copying. If the code is larger, then it will make little trouble for user. Because by using cursor sometimes mouse pointer become deselected. So the solution is to one click text selection from blockquote by using mouse pointer. After that we have to use copy option for further use of code. But some users may feel irritating. Though this is very simple widget but very useful. For watching demo you can click on code block on this post. Just click on it and all code will be select instantly. Because your blog visitors and code users will feel comfortable to use it. For installing this feature please follow the below steps- Step1Log in to yourBlogger Accountand Go to yourBlogger Dashboard Step2Click on Now click on-Template-Edit HTML Step3Now find the/bodyby pressing Ctrl+F (Windows) or CMD+F (Mac) Step4Copy the code from below and Paste the code above/before/body script type='text/javascript' var pres = document.getElementsByTagName(quot;blockquotequot;); for (var i = 0; i lt; pres.length; i++) { pres[i].addEventListener(quot;clickquot;, function () { var selection = getSelection(); var range = document.createRange(); range.selectNodeContents(this); selection.removeAllRanges(); selection.addRange(range); }, false); } /script Step 5Now simply hit theSave templateButton. Customization If you are using pre code instead of blockquote then replace blockquote with pre. If you want double click to select text then replace click to dblclick. That's it. Now you can check your blog and click on any code from block. And see all code block are select by one click. This really nice and user friendly for the Blog user.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.