{"id":433,"date":"2011-03-17T05:07:36","date_gmt":"2011-03-17T11:07:36","guid":{"rendered":"http:\/\/bateru.com\/news\/?p=433"},"modified":"2011-03-17T05:08:16","modified_gmt":"2011-03-17T11:08:16","slug":"javascript-code-of-the-day-get-highlighted-text","status":"publish","type":"post","link":"https:\/\/bateru.com\/news\/2011\/03\/javascript-code-of-the-day-get-highlighted-text\/","title":{"rendered":"Javascript Code of the Day: get highlighted text"},"content":{"rendered":"<p>Discovered the code below while browsing online. Inspired from <a href=\"http:\/\/www.codetoad.com\/javascript_get_selected_text.asp\">codetoad.com<\/a>.<\/p>\n<pre lang='javascript' line='1'>\r\nfunction getHighlightedText(){\r\n     return ((window.getSelection) ? window.getSelection() \r\n          : (document.getSelection) ? document.getSelection()\r\n          : (document.selection) ? document.selection.createRange().text \r\n          : null);\r\n}\r\n<\/pre>\n<p><b>Usage<\/b><\/p>\n<pre lang='javascript' line='1'>getHighlightedText();   \/\/ returns highlighted material as a string.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Discovered the code below while browsing online. Inspired from codetoad.com. function getHighlightedText(){ return ((window.getSelection) ? window.getSelection() : (document.getSelection) ? document.getSelection() : (document.selection) ? document.selection.createRange().text : null); } Usage getHighlightedText(); \/\/ returns highlighted material as a string.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,10],"tags":[30,164],"class_list":["post-433","post","type-post","status-publish","format-standard","hentry","category-frontend-tech","category-tutorials","tag-code-of-the-day","tag-javascript"],"_links":{"self":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts\/433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/comments?post=433"}],"version-history":[{"count":4,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts\/433\/revisions"}],"predecessor-version":[{"id":437,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts\/433\/revisions\/437"}],"wp:attachment":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/media?parent=433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/categories?post=433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/tags?post=433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}