How to View an iframe in Phonegap without Leaving Page? - javascript

In phonegap, I'm trying to iframe to the webapp hosted on a domain. The app needs to be disabled while in motion, so the index.html has the javascript that would freeze the page (IE, create an absolute div that would prevent you from touching anything inside the iframe) if moving faster than a certain speed. However, I can't seem to iframe the way normal browsers do. An iframe immediately opens in a browser window, and even with ChildBrowser installed the iframe is still separate from the parent view, so my javascript to freeze the app would no longer apply.
Is there any way to have an iframe work the way I'm trying to get it to in Phonegap?

Related

Prevent Specific JS Loaded by iframe from Running on my Site

I want to know if it is possible to block JS, loaded by an iframe, from running on my Wordpress site. I currently embed iframe generated by a service I pay to use for my business. The iframe comes with Google AdSense ads embedded in it. Recently, the rogue pop-ups have been affecting my customers. Essentially, these are ads that run on the mobile version of my site and initiate a series of redirects. I can prevent these on my own device with an AdBlocker, but not all of my customers are that savvy.
I have tried to disable the Google AdSense ads a few ways: CSS display:none; (fails, as the JS is loaded even if the element is hidden with CSS), PHP (created a plugin that leverages wp_deqeue_script, targeting the google ad script files (blocks some JS, but ultimately fails to prevent every instance of the ads), and even HTML in the head section of my site, (the idea is that it prevents loading sources outside my domain, fails).
Is there a way to programmatically prevent these JS files from loading on my site?
There is not so much you can do about it. As #charietfl states in the comment you should think in the first place about not embedding this at all if that is a possibility for you.
From programming perspective there is only one reliable thing you can do: use iframe sandbox mode.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
This way you can prevent the IFRAME target from running ANY scripts - I do not know though if its a valid scenario for you. Otherwise there is actually no reliable way to affect the loaded iframe.

Chrome extension hidden / non-displayed tab

Part of my extension involves accessing a webpage and then programatically performing certain functions for the user. The app would obviously be much cleaner if the user did not have to see all this happening in a browser window.
In some situations this could be achieved by, displaying other content (useful to the user) in a browser window, loading the screen with the programmatic elements in an iframe and manipulating them through an action script that triggers on the page load of the page loaded in the iframe.
However, for my purposes this is obstructed partially by the cross-domain limitations and totally by the fact that site in question does not allow iframes.
(One solution was to reverse this process--i.e. direct the browser to the correct page and throw up the useful content in front of it, thereby hiding the noise while loading the page in the browser. This works but it is horrible for obvious reasons)
Is there any clean way to either:
Open a chrome window but keep it hidden?
or
Load a page (i.e. have a DOM built etc) without doing so in a window/tab?
Have you tried using
chrome.windows.create({url:yourUrl, focused:false, state:"minimized"}, function(hiddenWindow){
//do whatever with hidden window
});
or having an <iframe> in the background.html of your extension?

how to make parent web page scroll to a specific position (at the top) from an iframe

My problem is similar to this
Scrolling a page to the top from an iframe (containing a gwt application)
But my iframe is made with vb.net and asp.net. and the parent webpages are external. i.e Third party websites uses our iframe to integrate in their webpage. and the all functionality of our web application is performed inside the iframe.
there are number of pages and form in our iframe. among them one page causes the problem. when this page loads it makes the webpage scroll to the bottom of the page automatically.
i want to make the parent webpage scroll to the top of the page from a page inside the iframe ( without making the users clicking on any button ).
how can i do that.
Try using the JavaScript's scroll function in the iFrame :
window.parent.scroll(0,0);

Can you capture a popup and load it in the parent/opener screen?

I am working on an app where I have a flash app that access a URL through an iFrame. The contents of the iFrame is 3rd party content. The content is a menu that you can navigate through but once you get to a certain point, the menu launches a pop up, and the popup is the continuation of the menu.
I was wondering if there is anyway that I could capture the popup and make it load within the parent/opener page, using jQuery perhaps to change the contents of the iframe?
This solution is probably way out there but I was just hoping for a nice quick fix.
The reason that this is a problem is that the app is for a tablet and the popup doesn't appear within an app on the tablet.
Thanks
If the iFrame content is served from a different domain than the parent/owner document, you're out of luck - that is, if you have no control over the iframe content. This is due to JavaScript's same origin policy.
If you are able to modify the web app running inside the iframe, you could try using window.postMessage (HTML5) to notify the parent window.

Force link in uiwebview to open in Safari - with JavaScript

This has a lot to do with my previous question:
detecting UIWebView with Javascript
I would like to force a link on my webpage to be opened with iPhones actual Safari Browser, and not in a UIWebView window, even if the app it's being viewed in tried to open all links in a UIWebView window to prevent users from going out of it.
Please note that this is not a duplicate as I'm trying to do this with Javascript/Client-side, not within my own native app (I own the page that's being viewed, but can't control which app is used to view it).
I do not think this is possible. I set up one of my apps to use a UIWebView only and never open Sarfari (though admittedly I allowed only pages within a certain domain).

Categories