Why chrome shows alert randomly when try to open custom protocol url with location.href? - google-chrome

i had took a look to another threads about chrome and custom protocol apps, but i couldn't resolve a doubt i've got. In my web app, when you click a button it fire a new tab with an webpage (window.open(url, "_blank")). The new tab is opened with the url (annother web app with https protocol). This url fire a javascript function on load that verifies some things and then generate a custom url, for example myurl://base64code, and put it in an existing iframe in this way windows.frames['myframe'].location.href=theCustomProtocolUrl. i tried in different ways (location.replace, create a new iframe and set the url, etc) and i always have the same problem. If i refresh (ctrl f5) the page it always show the dialog or if i open the link with the developer console opened. But if i click my button and the page is opened in a new tab it doesn't work only if i refresh (ctrl+f5). This works perfectly on IE11, it launch the app directly.
Any ideas why chrome, and edge, works like this?
UPDATE: I have found the reason, is i use the protocolcheck.js (https://gist.github.com/vladimirtsyupko/cfcd332476b16683bb0b) library.
First i tried to open a protocol with the timeoutHack (it use blur event) and then, after failing, it fires the other url (in this case https) and the dialog doensn't appear. I found a bug with blur event on chrome > 85 https://bugs.chromium.org/p/chromium/issues/detail?id=1137801
Thanks in advance

Related

Clicking link with target _blank makes browser close new tab immediatly

Clicking on a link to our webpage using
Link
opens a new tab and closes it immediatly. This happens on all browsers apparently. Deactivating adblock and alike does not change anything.
Using the url without target="_blank" or right click -> open in new Tab however works fine.
The web page is an angular project and does not use any sort of trackers. Furthermore this behavior started only recently, so I assume it's due to some change in the page.
Any hint why this happens or where to start debugging this?
Found it.
I had a line window.close(); due to a workaround for a popup for facebook login, implementing this:
Facebook Login not working in PWA app if app is in stand alone state

Navigation back causes page reload in Chrome

I have a single page PHP application that fetches data from a third party API and outputs the items in a product grid. Clicking on one of the products leads to an external url which opens in the same window.
When using the back button in Chrome to go back på the application after clicking the external link, the page reloads for some reason. I'm only experiencing this problem in Chrome, therefore I'm wondering if it could be a Chrome related bug?
Found the issue. It was caused by using a window load event incorrectly.

How to toggle Device Mode on a popup window in Chrome?

I have a web app with a chat that opens in a new popup window. Normally, in Chrome I can hit F12 and click the icon of a smart phone to toggle it. But in the popup window this icon does not appear. This is important for me since I need to throttle the connection of the popup in order to simulate a user disconnecting from the chat.
Thanks!
It doesn't seem to be currently possible. I've opened a ticket for you. Meanwhile you have couple of options:
open popup in a regular window (copy paste the url, or modify window.open call to open a new tab instead of a separate window),
create a Chrome extension that uses debugger API to send emulateNetworkConditions message to your popup window
or try hacking DevTools like so:
open DevTools (A) for your popup
focus on DevTools window and open another DevTools (B) for that window using a keyboard shortcut (F12/alt+cmd+J)
in the console of the DevTools B call WebInspector.overridesSupport.setEmulationEnabled(true) (to enable emulation) and then WebInspector.overridesSupport.settings.networkConditions.set({throughput: 1.5 * 1024, latency: 40}); (to enable network throttling)
Perhaps easier way as of today is to install chrome extension which will allow you to open preview in new tab instead of popup. There you can have the same icon to toggle to mobile. Below is the extension:
https://chrome.google.com/webstore/detail/tag-assistant-companion/jmekfmbnaedfebfnmakmokmlfpblbfdm?hl=en

FB.getLoginStatus callback not get invoked on back button click in chrome

I am using facebook's js SDK. I use FB.init to initiate the fb object and FB.getLoginStatus to check user's status. Everything works fine when load the page. But when i click some link inside my page and then try to go back to my last page by clicking back button of browser FB.getLoginStatus is not get invoke the callback. This problem occurs only in Chrome's. In all other browsers it works fine.
If i clear the browser catch and then go back then everything is working fine
I also remove the all extension that may causes a problem.
Thanks in advance.

How can I get notification of page load events in Chrome?

I need to be able to monitor navigation events (such as page loads or switching between active tabs) in browsers running on a Windows PC. So far, I can get this to work in IE and Firefox by loading a DLL into all running apps via a call to SetWindowsHookEx, then asking for either the IHTMLDocument2 (in IE) or nsIWebProgress (in Firefox) interface from the application. I can use the appropriate interface to request a callback from the application when an event of interest happens.
Is there a way to do this in Chrome? I have read a little about Chrome extensions, but I have not found any documentation on an API exposed by Chrome that is analogous to COM in IE or XPCOM in Firefox. Will a similar approach work or will I need to do something completely different? (I am working in C++.)
I would appreciate it if someone could at least point me in the right direction.
Thanks.
With Chrome extensions API you can register some events handlers for changing state of tab like when document state is changed (loading or loaded), when new tab is added/removed from window or when user switch between tabs.
More about tabs events You find on http://code.google.com/chrome/extensions/tabs.html#event-onActiveChanged