HTML5 PostMessage Cross-Domain Issue - html

I am attempting to use the HTML5 method 'postMessage'. I know this method only works in 'modern' browsers, but for my customer base, that is good enough.
Here is my situation:
A browser window on domain 'abc.com' opens a new window on domain 'xyz.com'. I own both domains, and I can put any javascript I need to on either side. From what I can tell, I should be able to use 'postMessage' to send messages between the two windows. This works in Chrome, but not in IE 9. I am unable to get a reference to the parent window from the child or vice-versa. If both windows are on the same domain, I do not have a problem.
So, is this a bug ("feature") of IE's implementation of 'postMessage'? Is there any way I can accomplish what I am trying to do?
Many thanks!

Unfortunately, IE's postMessage implementation only works between windows and iframes and frames. Trying it with a window.open will result in a No such interface error when postMessage is called, even though the debugger clearly shows the method existing.

Related

Can we do web push notifications in chrome without using GCM/FCM?

I am trying to do web push notifications in Chrome without using GCM/FCM. Is it possible? I'm not able to find examples on how to use a different push service.
No, it is not possible to use another push service.
In Firefox, you can do it by modifying the dom.push.serverURL preference, but obviously you'd need privileged access to alter the value of the pref.
There are third-party services that you can use to implement push notifications, but they will use the Web Push API under the hood (so Autopush on Firefox, GCM/FCM on Chrome).
Yes. Using VAPID spec and service worker you can use web push notifications without FCM/GCM. For more information please look into below google docs.
https://developers.google.com/web/fundamentals/engage-and-retain/push-notifications/how-push-works
I have used Using VAPID for WebPush. This works in Firefox and IE Edge browser. But not mail in Chrome browser.
Again in Firefox action seems to be not working. Whereas in IE Edge, notification actions buttons will work
It can be done using Service Workers. It's new w3c feature.
I've not tried it yet, but you can have a look at it:
https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/
It's not compatible with all browsers. Ref.: http://caniuse.com/#feat=serviceworkers
good grief the advice here is DISGUSTINGLY bad
yes you can do it using https websockets and also a Microsoft project called SignalR which doesn't even "need" browser support, i.e it will work in javascript no matter what
the reason I mention SignalR is that is DEGRADES the mechanic to the bet fit to ensure it works whatever the weather.. tools they use are
from old sckoole long polling
all the way up to WebSockets under the covers when it's available
(and gracefully fall back to other techniques and technologies when it isn't, while the application code remains the same)

How can I cast an HTML page with the Google Cast Chrome extension?

I'm building a simple web application that I want to be able to display on a TV screen using the Google Cast SDK, the Chrome browser and a Chromecast. I know with the Chromecast extension for Chrome Browser, I can cast a tab to a Chromecast device, which, from my laptop works perfectly. However, I want this exact same functionality, but available from iOS devices (iPads and iPhones) running the Chrome Browser.
It seems since Chrome v36 the Cast ability is baked into the iOS versions of Chrome. I have pulled in the Google Cast SDK per these instructions: https://developers.google.com/cast/docs/chrome_sender. I am able to get my iPad to connect to the Chromecast, but when I try to pass in a URL to a web page...
var mediaInfo = new chrome.cast.media.MediaInfo('http://google.com');
var request = new chrome.cast.media.LoadRequest(mediaInfo);
session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError);
I get an error...
invalid_parameter
I have found other, somewhat dated examples, saying I can build a custom Cast Receiver that holds an iFrame and renders the page in there, but I do not want to build a custom Cast Receiver.
Can I accomplish this with just a Cast Sender?
You always need a receiver on the chromecast; that is what gets loaded there. In general, you can either use a default/styled receiver or a custom one. The Default or Styled receivers can only handle media so you are left with the Custom option and having an iframe is the way to go.
Chrome on iOS doesn't support casting. There's a post from early 2016 saying this on the google product forums. (But my reputation is too low to post more than two links).
If it DID work, then all you would need to do is go to this site and choose the ChromeCast option and press Launch after typing in your website. This does work on Chrome on desktop.
The source for this sender/receiver is here: https://github.com/boombatower/chromecast-dashboard
I've used the boombatower.github.io receiver with my own code as sender in an iOS app. I'm also looking at whether an app extension would work, but I suspect not because of app extension limitations.

Is there any way to know if a download is happening

Is there any way to know if a download through a browser is happening? (I am thinking of creating an app,though whole concept relies whether this particular feature is possible or not)
For example: Say I start downloading a file from a web browser, and a program is running in the background( preferably written in Java) which can detect that a download is happening and it can get access to the link.
Ideally it should be able to detect from any browser, but even if it works with one browser it is fine for me at the moment! Any ideas if this is even possible?
I want to do the same thing. My first thoughts are :
1. Low level browser independent :
Sniff traffic and filter captured packets (Protocols HTTP/FTP + other filter rules). You may use WinPcap or even try the LSP approach.
2. High level browser dependent : Create browser plug-ins (BHO for Microsoft Internet Explorer, Extension for Google Chrome, Add-ons for Mozilla Firefox)

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

Masking a plugin (or applet) to show html content over it in Chrome on the Mac

For all other browsers that I've tried in both Windows and MacOSX (including Chrome under Windows) using an "iframe shim" works fine. However, I have not been able to get iframe shims to work over our plugin in Chrome on the Mac.
Having Googled the problem, and done some testing, it appears to depend upon the object. I've found an example using StreetView (a flash object) which works, and another example using a Java Applet which does not work.
Some links:
Here's a description of the method: http://www.oratransplant.nl/2007/10/26/using-iframe-shim-to-partly-cover-a-java-applet/
This example using a Java Applet is from the above article: http://www.oratransplant.nl/files/iframe_shim.html
And here's the working version using Streetview: http://gmaps-samples.googlecode.com/svn/trunk/streetview/iframeshim.html
By inspecting (and editing) elements in Chrome and copying the objects between the two example pages, it appears to be that the flash object just allows iframe shims (in Chrome on the Mac), but that the Java Applet does not.
In our case we are using a custom plugin, built with Firebreath.
It may be that I need to implement extra functionality into our plugin, mimicking whatever flash is doing, but this could well be caused by a bug in the Mac build of Chrome.
Can anyone help? We really do want to be able to show HTML elements over our plugin, and the iframe shim works on almost all browser/OS combinations!
The lack of compositing is a known bug in Mac Chrome with any plugin using Core Animation or Invalidating Core Animation. It will be resolved in some future version--in theory, you should never need an iframe hack on the Mac, and plugins should always composite correctly. If you are interested, you can detect whether compositing of Core Animation is supported dynamically in your plugin using NPN_GetValue with the value 74656 (see WKNVSupportsCompositingCoreAnimationPluginsBool in the WebKit source; this should be added to the formal NPAPI spec soon, but the value won't change, so you can hard-code it now and when Chrome supports it that will start returning true).
In general the iframe hack should work in recent versions of Chrome (what version are you testing?), but there are some bugs where it doesn't get noticed until the page gets a re-layout, so you might want to play with forcing that.
Note that your Streetview example isn't a valid test on Mac Chrome, because it's using wmode=opaque, which means it's using the CG mode, not CA mode, and thus compositing works completely regardless of the iframe hack.
What drawing method are you using? You shouldn't need to use an iframe over a plugin on Mac because all drawing is windowless, unless you're doing strange things that I wouldn't expect to be possible with Chrome (i.e. creating an opengl context over a coregraphics or quickdraw context). If you were doing something like that there would probably not be anything you could do.
One easy setting would be to just resize the plugin to 1x1 to effectively "hide" it.