inject javascript into page which loads in childbrowser phonegap - javascript

I have a link which opens in the child browser of phonegap - for those not familiar with phonegap just think of it as a new window.
The link that I am opening has an annoying alert which pops up the 1st time the webpage is loaded on the device. I would like to stop this alert poping up by trying to change the cookie the webpage uses to check if it has been loaded before.
Is this possible?
How would I go about doing this?

Little Difficult.
You could host your own html page remotely and enclose the page you are opening inside a iFrame which you could stop the alerts by some type of javascript. Or (using ajax) remotely retrieve the page you are after?

Related

Telegram Web App Bot, error redirecting to a new page on android

I can't redirect user on new page with javascript variants code:
window.location.href=url
window.location.replace (url)
window.location.assign (url)
The problem of redirect only on android, on other platforms there is no problem with going to another page.
How to fix it on android ?
View problem:
when going to any page
In order to solve the problem you have to understand it. This happens on the Android version of Telegram in WebApps. When you click on a link, it does not open in the WebApp area but in the browser.
This browser is Telegram's internal or external browser, depending on what was indicated in Setting/Chat Setting/In-App Browser.
This bug occurs regardless of the link. So not just with your Javascript calls. A simple produces the same effect.
It seems that it comes from a bug at the level of the WebView therefore in the code of Telegram. So a change in the code of your WebApp (another Javascript function for example) will not change anything.
Solution
The solution that I tested and that works is to use an iframe. Instead of having for example index.html which has links to page1.html and page2.html, you rename your index.html to menu.html and you make an index.html page which has an iframe containing menu.html.
If you put a borderless and full-surface iframe, the user won't notice anything.
And no need to go from menu to page1 or page2 with an iframe.src: direct Javascript links between pages that are in the iframe work perfectly, just like simple href links.
Just one point: you have to perform a window.Telegram.WebApp.ready(); in your first page so the one with the iframe (and also in the others)

Return focus out of embedded broswer

I am working in a desktop application that has an embedded browser. There is a process that loads a page in this embedded browser and sets the focus on it.
This is not wanted and disturbs. An interesting detail is that if I create an alert after the page gets loaded, when I click to close it, the focurs return to the "host" desktop application, which is exactly what I want.
Is there a way in javascript to tell "turn back the focus to wherever it was"?
Thanks in advance.

Popup or Child window in Java Script

Am developing a web application using phonegap. There is one issue where i need to bring a Child window on top of main window more like a popup. The child window is basically a notepad(textarea).
I tried to use onClick=window.open but it dint work in android emulator. And there is an api for phonegap which is loadurl .. but it actually takes to the next page (full screen) but not as an popup.
Could use ur inputs on How to create a popup window in javascript which works in android emulator
Thanks
Thilak
use http://dev.jtsage.com/jQM-SimpleDialog/
u can download from here http://dev.jtsage.com/jQM-SimpleDialog/demos/install.html

Bookmarklet on blank page

I've written a simple bookmarklet that opens multiple web pages with a single click:
javascript:(function(){window.open("http://www.w3schools.com");window.open("http://www.google.com");window.open("http://www.yahoo.com");})();
I wan't to be able to open the browser and click this immediately, but the bookmarklet won't work unless a page is already loaded in the window. I prefer to have my browser home page set to "Blank" for speed. Is there a way to make this bookmarklet execute without a page already loaded?
Also, I'd like the bookmarklet to replace whatever page is loaded in the window, if something is indeed loaded. At present, it opens 3 new tabs. I've tried the "_self" and "_parent" values for the "name" attribute on the first window.open, but it doesn't seem to work. I may not be formatting it correctly.
Any help is appreciated! Thanks!
It isn't possible to open bookmarklet in no page.
Instead, you can try to set your homepage to something like data:text/html,Welcome! (yes, it IS a working URL).
To open a page in the same tab, type:
location.href='http://www.w3schools.com'
I was having the same problem, and learned from the internet that if you go to your about:config, search for browser.newtab.url and change it to about:blank instead of the default about:newtab your javascript bookmarklets should work (just tried, and it's working!). This should be cleaner than doing a data:text/html message (in any case even if you set the homepage it doesn't work for every new tab, only once for a new window)

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.

Categories