Get gdocsviewer plugin generated content using jquery - javascript

I am using jquery.gdocsviewer.min.js plugin to read office and pdf documents in a website. The plugin is working fine. I am trying to get the content of the generated preview using jquery
var rowcontent=$('.embed').html();///embed is the class of the link
But I cant get this to work. Check a working fiddle
http://jsfiddle.net/4s8bn/133/
Please advice me on what to do or if its practical. I want to fetch the content and save it as html in a database.

In client side, it is not possible to get that pdf directly and save as html in database.You have to do it in server side. For server side,here is an example with php Once you get that in server side you can catch it with Ajax in client side.

Try:
var rowcontent = $('.gdocsviewer').html();
From the docs:
The plugin inserts a the IFRAME for the viewer inside an injected DIV.
The DIV tags all carry the class name "gdocsviewer", which allow for
styling all the gdocsViewer instances via CSS. If the anchor tag has
the ID attribute defined, then the injected DIV tag is also set an ID
attribute in the format of ID_of_Anchor + '-gdocsviewer'. See the demo
source code for more details.

Related

Go lang executing javascript for retrieving text in page

I'm trying to retrieve text that is loaded dynamically from a web page using golang.
The text to retrieve is on this page :
https://www.protectedtext.com/testretrieve?1234
This text is encrypted by a password and then decrypted on client side and loaded dynamically on the page.
I already tried with goquery by selecting 'textarea' object, but I can't get the text cause it's loaded dynamically.
How can I achieve this ? By executing JS in Go ? It's working in my chrome console, but no ideas on how to do that in Go.
A lightweight solution is the best for my project. Or any other website that can store and edit same text without modifying the URL ?
You may need a headless browser to load the javascript like for example phantomgo
However looking at the page source code we can see that they use sha512 for the tab title and aes for the textarea field.
The page which you shared contains https://www.protectedtext.com/testretrieve?1234, only one element of class textarea-contents
simple get class documents using goquery and get 0th part

Constructing full HTML page

How can one load a HTML file and run javascript embedded in it to construct full HTML page programatically in the same way as done by browsers?
Edit 1 - I have an application where I am trying to read some data embedded in an html page of a remote website. However, after fetching this page from remote website, I don't see that data because that data is actually loaded by a javascript embedded in this HTML page after browser loads initial markup. So, I need a way in my application to trigger javascript embedded in the HTML page in order to construct full HTML page.
If you mean that you have an HTML file stored on your computer, the only way that you can compile it is with your browser. Just enter the absolute file path in your browser's url input. If I misunderstood your question, leave a comment and I'll correct my answer.
Question needs more details, but depending on what you want:
If you want to dynamically load different HTML documents, see iFrame
If you want to insert elements to an empty html document:
First, make a blank html document
<!DOCTYPE html>
<script src='main.js'></script>
</html>
Then in main.js do:
var html = document.querySelector('html');
// Append remaining page elements to the html element here.
// (the `head` and `body` elements may have been automatically created)
// You will need createElement and appendChild
createElement
appendChild

Get data for AJAX tooltip from URL adress

I am using this script for tooltips.
Is there any way to load content of tooltip from URL(dynamic loaded content from PHP script) instead of using path to html/php file?
Example
I need this:
Some link
instead of:
Some link
I had a brief look at the plugin, and you should be able to use /site/getcontent/1 without any issue.
Some link
(I'm assuming is being loaded on the same domain of your html file)

Run textarea to iframe

I'm trying to run an HTML, CSS and JavaScript code written by the user in a textarea on an iframe in the page, something like jsFiddle. I tried using this for the HTML and CSS:
$(".runBtn").on("click", function(){
$(".Result > iframe").contents().find('body').html("<style>" + $('.CSS > textarea').val() + '</style>' + $(".HTML > textarea").val());})
But it doesn't seem to work. And I still haven't got a clue on how to run the javascript on it.
Comunication with iframe is tricky and You should not be using it like that. There is API for communication with iframe no mater it is from site to iframe or iframe to site. I didn't use it for a long time so i can't give you some good examples but You have everything You need on 1
it goes down to that you send a message trough that API to iframe with some payload, and inside of him You have event listener to that message event. when you receive it, render html from payload.
$("runBtn") is looking for a elements that are a tag <runBtn> that most likely doesn't exist. If element has an id you need a proper id prefix
$("#runBtn")
As for your html you haven't created a proper <style> tag. Also not clear where the textarea is in relation to iframe (inside iframe or outside). If it is inside you need to use find() within iframe contents to access it

Adding CSS Class Based on URL with Javascript or Jquery within Wordpress Template

I am attempting to write a small script which will look at page URL and, based on what URL it sees, add a new class to an HTML element. More specifically, on this page:
http://pamaphilly.wpengine.com/volunteer/
I'm going to add a class for the active URL which will add an arrow marker to the appropriate left hand nav marker. I have tried this strategy: jQuery add class based on page URL and, when I used the script on a dummy page, it works fine. But when I try adding it to the Wordpress Template, nothing happens. I've tried adding the script at the bottom of the template file and just (as a test) embedding it in the php template. I'm guessing my failure relates to a Wordpress issues (probably a failure of knowledge on how to do this) but I would appreciate any guidance.
Thanks.
You need to include .slick before you can use it. (before script.js + in the same way you include your script.js file)
Why not do this with CSS and WordPress directly, and skip JavaScript?
You can use WordPress's body_class() function to dynamically add a class to the <body> of your page. Using CSS, you can then target your appropriate .volunteer .sidebar-member li via CSS.

Categories