Google Chrome Extension Adding iframe from source - google-chrome-extension

I'm trying to load myframe.html inside an iframe and attach that iframe to the DOM of the current page. Is this possible, if myframe.html is part of my extension source?
I was thinking something like
var iframe = document.createElement("iframe");
iframe.setAttribute("src", "myframe.html"); //what would be my path here, if this were possible?
document.body.appendChild(iframe);

It should be possible, use a content script to inject javascript into the page and then use the chrome.extension.getURL() method to get the correct URL to your file hosted inside your extension

Related

Firefox OS - Launch external link inside Firefox OS app and retrieve its content

I have a Firefox OS app in which I have opened an web page via mozbrowser attribute.
<iframe id="inlineFrameExample"
mozbrowser=true
src="<some external link>"
</iframe>
How can we retrieve DOM content of the iframe?
You can retrieve DOM content via executeScript() method present in Browser API. It will run the script against the iframe and will allow you to do DOM computation tasks.
Note: The example mentioned in the document didn't worked but the syntax given below worked for me. The diff is is passed as string.
iframe.executeScript('put_your_script_here', {origin: 'domain_name'});

Controlling a web page, casperJS like : can that be done with chrome extension?

I am trying to develop a chrome extension to automtize some tasks on the web (fill form, go to next page, extract data...)
The idea is to develop a kind of http://casperjs.org/ as chrome extension.
I am injecting some JS to an active tab.
JS is run, and everything works fine: problems raise when I navigate to a new url.
When the page navigates to new url (document.location for instantce), the JS stops running since it is unloaded.
My idea would be to store the JS state and resume it once page has loaded:
ex content of source variable: I inject it in background to the web page.
for (i = 0;i < 5;i++) {
document.location = "http://www.example.com/page"+i;
waitUntilPageIsLoaded();
var source = $("body").html();
extractData(source);
}
chrome.tabs.executeScript(null, { code: source });
Of course this does not work since we change the location of the page.
Or more generally speaking, can casperJS can be developped using google chrome extension ?

NodeJS Get Completely Rendered HTML Page

I want to get a html page content from a url using NodeJS after JavaScript is fully loaded and the page is completely rendered, or get the basic html then run all JavaScript files to achieve final content.
For example let's assume there is a website based on AngularJS, so the basic html is simple, but after loading all JavaScript codes in the page, page content is completely different. I want to get that final content on my server to find something in it. Any ideas?
After-Load is a NodeJS package that works like a charm :
var afterLoad=require('after-load');
then :
afterLoad('http://stackoverflow.com/questions/29366718',function(html){
console.log(html.indexOf('charm')>0);
//true
})
Maybe it's too late, but back in the day, PhantomJS solved my problem.

sencha touch :: is it possible (and how) to open a website inside a panel or in external browser window?

i wonder if and how it is possible to open a website inside a panel or in an external browser window of the mobile safari! I tried to open a website inside a panel but due to crossdomain problems only the htm without the css was loaded.
any ideas?
thnx!
edit: let's say, we use phoneGap
As far as I know, cross-domain issues do block you from IFRAME solutions for displaying external links inside your app.
Best solution currently is to have links include target="_blank" to force a new browser window to open.
#Stevanicus #Dalar It does open a new window in Mobile Safari if you use Phonegap and allowed domains using phonegap.plist whitelist property, but if you do somthing like
var rateMsg = Ext.Msg.confirm('Title', 'Some message', function(e) {
if(e == 'yes')//If user confirms yes
{
window.open("http://www.example.com", "_blank");//We open a link with _blank to use mobile safari and not your webview
}
});
It does not work.

Download link page JSF

How can I produce a URL which somebody could open and that would immediately download a file e.g. pdf?
I have been using ice:outputResource but that requires the user clicks on a link. Is it possible to do this in JSF?
Thanks,
Dwayne
You want to download a PDF file immediately when one opens a page? Use Javascript to fire the request on the PDF file during page load.
<script>
window.onload = function() {
window.location = 'http://example.com/context/path/to/file.pdf';
}
</script>
Update: your question is actually ambiguous. From other point of view, are you asking how to return a PDF file on a GET request? If so: if it's a static PDF file, then just put the PDF somewhere in the webcontent and link to it. Or if it's to be dynamically generated or served from a database or local disk file system outside the webapp, then create a servlet which does the job. Example here.

Resources