Reputation: 6970
I'm trying to automate a process of putting items in a basket on another domain. Naturally I'm dealing with all kinds of cross-domain issues. The only way I can get it to work is by opening the other website's "Add Product" page in a seperate window supplying a product id and amount.
To make this work as smooth as possible, I'd like to open these popups in the background and then close them when all items have been added.
This works fine in Chrome, but especially IE is giving me problems. I can't get it to A) open a window in the background (by calling .blur on the new window and .focus on the current) and B) I can't close the popup I've opened with .close().
Is there any way to make this work, or at least work better?
Example:
var url = 'http://www.example.com'; var v = window.open(url, 'basket').blur(); window.focus();
Ideally I'd like to solve this by doing a JSONP call instead, but I have no way to make or induce any changes to the website I'm calling.
Upvotes: 0
Views: 650
Reputation: 147363
This qpproach is doomed. Popups can be blocked by browsers, users can also disable a script's ability to move, resize or focus windows.And you can't control the popup once it's open (like send it more product ids or proceed to a checkout or whatever).
Find another strategy that does not look like something designed to hijack a user's browser.
Upvotes: 0