I have an Android application with webview. there are two pages with an iframe that shows pdf using google docs. My problem is that loading this: javascript:document.getElementsByTagName(\"iframe\")[0].src = document.getElementsByTagName(\"iframe\")[0].src; works only for one of those pages. The strange thing is that there is no problem if I other url when changing the src (for example a picture). What could be the problem?
Are you using the right index for the 2nd frame?
javascript:document.getElementsByTagName(\"iframe\")[1].src = document.getElementsByTagName(\"iframe\")[1].src;
I figured it out. The problem was in the src url. I had to parse it before I use it.
So we should always check what url we use for the iframe.
Related
I am trying to automatically download a plugin on my wordpress site by implementing phantomJs. For some reason, I cannot seem access the download button (shown below)
This is the HTML code to the image (with domain sensitive information blurred out for security purposes)
So far, I have tried accessing this element by using the following code:
function() {
page.evaluate(function() {
let mainLink = document.querySelector('a[data-slug="better-wp-security"]')
mainLink.click()
})
}
Some things to mention:
This function, as it is part of a larger file, will NOT execute until the page has finished loading.
PhantomJS is executing correctly, there are no problems with permissions
The script before-hand is properly accessing the install plugins page, which I verified by capturing screenshots before trying to click.
I have defined click earlier int he file, it works perfectly.
Any ideas how I can accomplish this? Thanks all!
ADDED INFORMATION:
It seems as if the path from the main div element is as follows:
#the-list .plugin-card plugin-card-better-wp-security .plugin-card-top .action-links .plugin-action-buttons .install-now button
I imagine the solution to this question has something to do with this sequence.
I was able to accomplish this by now going after the data-slug attribute, but rather going after the href element itself. Although I can't generate my own wponce value without the use of the Rest API, I was able to search the document to find an href that contained certain parts of the url. This is the final code below:
document.querySelector('a[href*="action=install-plugin&plugin=better-wp-security"]').click()
That's it! Simple and easy!
I am currently working on http://rightinfo.co.in
When I am trying to share this site on a FB page it is showing an image that I have not included in my site.
I have tried by adding ?v=1 to the url and url shortner services.
In facebook debugger also , the image is not showing. But in actual sharing , unknown image is showing.
Please help me to solve this
Thanks
You have issue with tags Please check this facebook debugger it explains alot Facebook debugger
It's because the og:image (see here) meta tag is set. This tag defines the image, which will be shown on facebook.
To change this image, try to edit this tag, take a look at the theme settings.
Another way is to change/delete the image itself, e.g. via FTP.
You can find it here: WEBROOT/wp-content/themes/Morpheus/img/portfolio/folio01-preview.jpg
Btw, I see you are using wordpress, I'd consider using a SEO plugin, which makes a proper use of the og-tags as explained here
I'm using jsPDF to create a pdf that will be displayed on a web page but I can't seem to get it to embed correctly. The pdf does load if I put in doc.output('dataurl'); but it loads in a new window (I know that is what it's supposed to do). I made a div that uses object tags to hold the pdf and it does load a pdf file but it wont the load the jsPDF. What I'm trying to do is make an embedded pdf like the one on their main page, https://parall.ax/products/jspdf. What code would I need to add in order to get it to load in the object tags? It has to be possible since they have a working version.
p.s. I'm using JQuery if there is a quick shortcut in there.
Thank you for your help.
EDIT: Ok new problem. So I added this: $('#ID').attr("src", doc.output("dataurlstring")); It works but it makes a new problem. It doesn't always load. Sometimes it loads just fine, other times it will load the div but not the iframe or content. There aren't any errors and all my console.log() lines run. How can I fix this?
Simple question.
I cannot get a new opened window to use CSS.
var previewWindow = window.open();
$(previewWindow.document.body).append(data);
The data is just a stringbuilder generating html from our backend.
The problem is, I want the newly opened tab/window to use Twitter bootstrap, either CDN or use the file.
I cannot get it to work with, what I tought should be the solution
$(previewWindow.document.head).append('cdn or path goes here')
I cannot seem to find anyone else with this problem, or I need a lecture in Google.
As you can see, in the head the CDN is properly added. But the html isn't using any of the CSS.
You're using protocol-relative URLs.
However, since you don't pass a URL to window.open(), it displays about:blank.
Therefore, it tries to load about://netdna.bootstrapcdn.com/..., which doesn't exist.
You should use absolute URLs that include a protocol.
I wonder if it is possible to get the page title of an url within IFRAME. I tried to use jQuery $('#iframe').attr('title') but that doesn't work. Please help. Thanks.
I think this is what you're looking for:
$(document).ready(function()
{
alert($('#iframe').contents().find("title").text());
});
That will return the page title that is located in the <title> tag of the iframe document that has the id "iframe".
I misread your question.
$('title', frames[frameName].document).text();
If what you are looking for is a way to get the URL of the iframe after the user has clicked on a link within that iframe, this is not possible in any modern browser that blocks cross-domain attempts.
Even though the iframe is part of the DOM and you can easily find the new iframe URL using apps like Firebug, Firefox will throw a XSS error on any attempts by js to directly pull that info.
But for the record, as it's already been said, the location within the DOM of the actual URL of the iframe content is (with a little help from jquery) : $("#id_of_iframe).contentDocument.location.href
I'm not totally sure if the above points straight to it with the above syntax, but that's the gist of it. The part that is a no-no is trying to go inside that contentDocument part.