I am using the facebook dialog feed to allow the user to post a message to their wall.
You must provide a redirect_url for the page to redirect to after it has submitted,
I want on the page it redirects to to have some code which simply closes the windows.
I tried using
<html><head><title>Close</title></head><body onload="window.close();"></body></html>
and
<html><head><title>Close</title></head><body onload="self.close();"></body></html>
but to no effect.
(note that my testing is simply me opening a new tab with this url, could that be the issue?)
You can only close windows with javascript if they were opened with javascript.
Otherwise, try looking at this question: How can I close a browser window without receiving the "Do you want to close this window" prompt?
Related
In my current implementetion of two-factor auth, I'm sending a SMS to the user with a link. When the link is clicked, the login proceedes on the users machine.
However, on the phone the browser will open up a empty page (since I'm currently returning 204 from the webserver for the link clicked in the SMS.
What I would like to happen is that when the user clicks the link in the SMS, the broser is not opened at all. It should just send the GET request, and the user will not have to close the browser window on his phone.
If that is not possible, is it possible to make the window that get's opened to autoclose imediately?
The browser has to open to make the request. There's nothing you can do about this.
However, if you control the content from the web server, you can attempt a window.close() on-load. Realistically, you'll probably get blocked on this and should also have a fallback content that says something like, "logged in, please close this window". (You can probably call window.close() on a button click.)
I'm using this URL :
https://www.facebook.com/dialog/share?app_id=xxx&display=popup&href=' . urlencode($url) . '&redirect_uri=' . urlencode($url)
I use window.open to open this in a popup window.
Ideally when I click on cancel I simply want the popup window to close.. but only when I know for sure that it's a popup window. So the behavior should be different for mobile browsers, I presume?
How can I do this?
The best solution is typically making the redirect_uri go to a page on your server that does a simple JavaScript window.close().
Mobile devices shouldn't be a problem - they open in an new window instead of a popup and window.close() works in the same way. Consider including text saying something like "You may now close this window" in case the user doesn't have JS enabled or window.close() doesn't have permissions for an unusual reason.
I am opening a popup after main window load.
Problem:
When user actually click on link the popup opens without complaining anything.
But when I am using Javascript call to click on href, I am getting popup blocker.
I am suspecting that, browser identifies that, popup is opening without any actual operation by user and that's why it is blocking popup.
In herf, I am calling a javascript method to open the popup.
I searched all the questions regarding opening popup and simulating the click like this, these works fine to simulate the click but still getting popup blocker.
Is there any workaround to fool browser?
You can't fool the browser per-se in this scenario. You could however, launch a div as an overlay on the main window if that's an option.
In order to process special URLs in an already opened web application I use this approach:
the user receives a special URL in an email (alarm notifications)
the URL opens a small helper web page (H) with JavaScript code that temporarily sets a session cookie
the main web application (M), which is already open in another tab/window, recognizes this and handles the request after deleting the cookie
the helper web page (H) identifies this as a success and is now useless and should be closed.
This all works fine except for the helper window (H) remaining open.
Of course there is a small text saying "please close this window now" but it would be perfect if it could do this automatically.
window.close() causes a confirmation dialog in IE and FireFox just ignores the command. I understand this is because the window has not been opened using window.open().
Similarly, calling window.focus() in the main window does not do anything, either.
Does anyone have an idea how to accomplish this anyway? At least, automatically focusing the main window without closing the helper window would be better than nothing.
Of couse I'm also open for other solutions to handle e-mail links in an already open web application... :)
Note the web application (and the helper page of course) are on a HTTPS server.
In some browsers, a window can only be silently closed through javascript if it was opened via javascript (for security purposes).
This code is a hack to get around this security measure:
// open a new window, replacing the current one
window.open('', '_self', '');
// close the current window, which was now technically opened via javascript
window.close();
Use at your own risk. These measures are in place to prevent you from doing annoying/malicious things to visitors of your page.
I have a web application, and I want to disable the Back button.
I read and found that I can open the browser without the navigation controls with the function window.open(...).
This is the code:
window.open (mywebappURL,"mywindow","status=1,toolbar=0");
I tried to put it in my Main.Master page, but I get an infinite loop and the new window is opened as a popup window of my application.
Does anyone knows where should I put this code to get my web application opened in a browser without navigation buttons?
Thanks,
Inbal.
try this on the link's onclick() event
function openPopup(){
var pathname = (window.location.pathname);
window.open(pathname+'somePopup.html','','width=800,height=450,resizable=yes,dependent,screenx=80,screeny=80,left=80,top=20,scrollbars=no');
return false;
}
and in the html
click me
To answer your question directly, make sure the window you're opening is a different URL than the window that's initially visited. So your visitor might arrive at www.example.com/index.html which then opens www.example.com/popup.html
If you open index.html again, the new copy will immediately open a popup, which will immediately open a popup, and there's your infinite loop.
However, as several people have commented already, this is generally discouraged. Among other disadvantages to this approach, popup blockers will likely interpret this as trying to launch a popup advertisement, forcing your visitors to recognize what's happened and change their settings.