summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2017-03-28 12:39:02 -0500
committerKyle K <kylek389@gmail.com>2017-03-28 12:39:02 -0500
commitbcd40d9580bfd1c08708b265e09d05f38659237e (patch)
tree62d0145b057289c05c83b8229611269cb9c0e5e0
parente6620b104d5349c1ccdc26508d5df8f8ae7401b6 (diff)
downloadjsexamples-bcd40d9580bfd1c08708b265e09d05f38659237e.tar.gz
jsexamples-bcd40d9580bfd1c08708b265e09d05f38659237e.tar.bz2
jsexamples-bcd40d9580bfd1c08708b265e09d05f38659237e.zip
CL post xhr snip
-rw-r--r--cl-get-postingbody.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/cl-get-postingbody.js b/cl-get-postingbody.js
new file mode 100644
index 0000000..26d0ec9
--- /dev/null
+++ b/cl-get-postingbody.js
@@ -0,0 +1,13 @@
+// use it like this: onmouseover="getCLPostBody(this)" in <a> tag where its href contains URL to CL posting
+function getCLPostBody(l) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('get', l.getAttribute('href'), true);
+ xhr.onload = function () {
+ var clpost = new DOMParser().parseFromString(xhr.responseText, "text/html");
+ clpost.documentElement.innerHTML = xhr.responseText;
+
+ var postbody = clpost.getElementById('postingbody').lastChild.wholeText.toString().trim()
+ return postbody;
+ }
+ xhr.send();
+} \ No newline at end of file