diff options
author | Kyle K <kylek389@gmail.com> | 2017-03-28 12:39:02 -0500 |
---|---|---|
committer | Kyle K <kylek389@gmail.com> | 2017-03-28 12:39:02 -0500 |
commit | bcd40d9580bfd1c08708b265e09d05f38659237e (patch) | |
tree | 62d0145b057289c05c83b8229611269cb9c0e5e0 | |
parent | e6620b104d5349c1ccdc26508d5df8f8ae7401b6 (diff) | |
download | jsexamples-bcd40d9580bfd1c08708b265e09d05f38659237e.tar.gz jsexamples-bcd40d9580bfd1c08708b265e09d05f38659237e.tar.bz2 jsexamples-bcd40d9580bfd1c08708b265e09d05f38659237e.zip |
CL post xhr snip
-rw-r--r-- | cl-get-postingbody.js | 13 |
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 |