I am trying to open a window based on a server call, but that window is blocked by browser as popup for certain users.
Here is the sample of code of what I am trying to do
<a onclick="validateuser()"></a>
In validate user, I am sending request to an external server.
The server sends response to another method openwindow()
In openwindow() I am calling window.open to open the particular page.
When I call openwindow() directly on onclick, the user is not blocked by popup.
This can't be fixed - the behaviour is by design. You need to tie your pop-up directly to some user action (like clicking a button) or find another way. You could open up a <div> with an <iframe> inside, perhaps.
Related
In my ember application, I have a dialog box with 'OK' and 'Cancel' buttons. On clicking on 'OK', an action will be triggered in which an ajax request will be sent and in its success, a new tab with a certain url has to be opened. I tried triggering a click in the success of the ajax request, but the pop up gets blocked. Here I want to use an
<a href=url rel='noreferrer'>
rel='noreferrer' because I want the new tab to occupy seperate browser memory and not that of the current window. Hence I cannot create an element with window.open() before the ajax request and then change the location(url) in the success of it. ( new tab opened using window.open() will occupy the memory of the window from which the new tab got triggered). It would really help if I could get a solution. Thanks in advance :)
While you are looking for a method to trigger a click action, it sounds like more broadly you are trying to create a noreferrer popup from inside of a javascript function. I think this would be possible using a two-part approach:
Open a new popup using window.open() containing only a small script tag. This will not trigger the popup blocker, though it would still be sharing the linking page's memory.
Use the script tag (inside the popup) to trigger an HTML meta redirect (which incorporates the no-referer option as described here.
Note that you cannot do this in a single step, as you can't do an HTML meta redirect into a new window, only the current window (source).
I am creating a Chrome application, "not a extension."
People can receive and send messages. If i receive a message, i got a notification and a mp3 sound. If the app Window is open, I know how to focus the window to make it appear to the front. but if the window is closed. I do get the notification, the sound ect (from background.js) and i create a window to open, when i receive this notification, but i can't interact with the background.js script anymore. is like if the chrome.runtime.sendMessage fire to soon before my app window is fully open.
chrome.runtime.sendMessage({
action: "Messageincoming"
});
When a message is incoming, in my app, a popup appear telling the user that a message is incoming (called from background.js) and the user can accept it by clicking a button. but when the app window is closed i should open a new window and i open it programatically with chrome.app.window.create('myapp.html', {
Like i said the chrome.runtime.sendMessage seem to fire to soon before the window is fully open. I can't trigger this popup to make the user accept, and i am not sure that if i do that the button will work.
Is there a way to wait until the window is fully open? or use any other method.
i read all the chrome app documentation and i find nothing. I have a js scripts in the myapp.html page who control the click and everything in the UI. controler.js
There are a variety of ways to do this, so it really depends on what you're looking for. The likely simplest answer is through a callback function, which you can pass in to chrome.app.window.create as shown here. This will allow you to pass in a function to be executed during page load.
Another way is to receive a message as you've described. You can do that as well, but you need to set a message handler in the new page you've created, and it needs to be set immediately on page load or else you will miss the message as you've described. Here's more on message passing with some examples at the bottom. https://developer.chrome.com/extensions/messaging
A more elaborate method of doing this could be to hook into the OnFullscreened or other handlers for the new window. In that handler, send a request to your background script requesting whatever message data you need. In your background script, have a message handler that returns whatever stored message(s) you want.
I have a script where it opens a window for online application after executing some other scripts.
window.open() is not called on any click. It is getting called in a script and browser prevents the new window from appearing.
How to overcome this?
Here is the code:
window.open('/search/applyonline?jobid=".$jobDetails->getIdjob()."',
'applyurljob',
'height=550,\
width=800,\
toolbar=no,\
directories=no,\
status=no,\
menubar=no,\
scrollbars=yes,\
resizable=yes,\
left=200,\
top=250')
Popup blockers will block windows from being opened that are not in response to a click event. Therefore you can:
Ask your users to turn off their popup blocker (not nice).
Change your scripts to work in response to a link or button click.
Use fake windows such as a jQuery UI dialog.
There is an iframe on my site which is hosted on another domain. It can communicate to the main site via window.postMessage. I do have a button on that iframe which calls a JS method on the main domain, which then triggers a new window.
It all seems good but since the user click event is generated on the iframe domain and window is created on the main domain, browser thinks that this is an automated popup, and blocks.
Is there anything I can do to prevent browser from blocking the window?
since that is browser based you cannot overwrite browser settings. But you can use javascript "modals" which are very useful since they are not pop-ups but they don't have the functionality of an pop-up
On an html page i click on a link and i get a dialog which loads server content through an ajax call.
I cannot change the javascript that created this dialog neither the ajax callbacks .
I have the need to access the href of the clicked link from another javascript to change some content loaded into the dialog from the ajax call. This after the dialog shows up.
As i can only read the window.location of the current page (the page containing the dialog, not the page loaded into the dialog itself), is there a way to get the href of the clicked link that caused the dialog to show up ? (ie. the GET parameters of the ajax call)
Attaching a callback for every clicked link doesn't work reliably because i have to catch just the last one that caused the dialog to open...
-- edit --
Well i'm using jquery, but i don't think it's implementation dependant.
The question more generally is: if i cannot access the ajax callback, is there a way to obtain the url in the GET request that caused a div (some content) to update ? (assuming you can call a javascript function after the div is loaded, inside it).
ie. if it was a popup (window.open) i just have to read window.location to get the page called, but as it's a div loaded from an ajax request, how i can get the url called ?
thanks anyway~
Install Firefox (if you do not have it already)
Install Firebug extension
Enable firebug for your site
Click the Link that launches the dialog (reproduce the situation)
Open the firebug window (bottom right corner of firefox)
Under Net - >XHR tab you can see the exact URL call with all GET/POST parameters that was triggered.
Then explore firebug some more to see what other possibilities it offers!