Is there anyway to check twitter login status like FB.getLoginStatus(response)? I want to hide the pop-up window if the user already logged. Right now the user has to click the button and every time the window will pop up whether the user logged or not:
$('#twitter').change(function() {
if($(this).prop('checked')){
hello('twitter').login(function(e){
if(e.error){
$('#twitter').prop('checked',false);
}else{
var twitter_oauth_token = hello('twitter').getAuthResponse().oauth_token;
var twitter_secret = hello('twitter').getAuthResponse().oauth_token_secret;
}
});
}else {
}
});
Looking for the same. I remember doing it years ago with testing image cache, but I am pretty sure that hack is long gone by now. I will have to check some old code. If only I could think of the project I used it on.
Related
I try to find Q&A related to my question. But I couldn't find. I have created a code where if user click double or multi click at single link then he will redirect to error page.
My Code is
<script>
var doubleClick = false;
function myWillPageRedirect() {
if(!doubleClick) {
doubleClick = true;
window.open("errorPage.html");
}
}
</script>
But this is not working. Why?
I want to create a secure page generally we can see in some bank or financial website.
I want to create 'if user click window back button then he will redirect to error page.' OR if if click refresh button then same action will perform and redirect to error page. ..
If this all code can make in Linux server backend code. It would be great.
Please help. I am not saying to some create code for me , I am asking for help to some correct my code above or bit extra help to make them secure.
Thank you .
HTML:
Double-click me
JS:
if(performance.navigation){ //Check if the page was refreshed
if( performance.navigation.type === performance.navigation.TYPE_RELOAD ){
myWillPageRedirect();
}
}
function myWillPageRedirect() {
window.open("errorPage.html");
}
window.onhashchange = function() { //Check if the url has changed (in case of pressing back button)
myWillPageRedirect();
}
More infos about Performance.navigation
I am building a web app and I am trying to do a function where there is a popup confirm box that shows after the user has been inactive for 10 minutes. When the popup opens the user can choose to continue being logged in or not. I need this box to close down after 1 minute if they have not answered the popup. How can I do this. Everything else works fine.
This is my code:
function checkTime () {
setTimeout (function () {
var dialog = confirm ("Do you want to continue being logged in?");
if (dialog == true) {
checkTime ();
} else {
window.location = 'LOGOUT URL';
}
}, 10000);
};
You cannot do that with the native confirm() as it stops JavaScript run on that page until the user has clicked on it.
So, You have to create a plugin for confirm-box or try someone else.
And they often look better, too. :)
you can't make the confirm close itself - as a thought path my bank has the same sort of thing on their on-line banking system - quite simply if you walk away and come back, it you've been longer than 10 minutes it doesn't matter what you chose it apologizes and logs you out anyway
the dialog requires human interaction it can not be overridden for security reasons. in order to do what you are trying to you would need to use a modal solution (this can be achieved with a small amount of js and some css if you don't want to use a third party solution)
I know it's not the answer you were looking for I'm sorry but hopefully it gives you some ideas for options
i have a confirm message which is showing when page is idle for some time in javascript . The confirm pop up came once the session time out. At that time if we give any response to the confirmation pop up it will do the corresponding process. My requirement is if we are not giving any response means i need to force the browser to close.. can anybody help me on this?
window.setTimeout('checkIfContinue()', 5*1000);
var sFlag=0;
function checkIfContinue()
{
window.setTimeout('idleTime()', 5*1000);
if(sFlag == 0)
{
sFlag = 1;
if(confirm("Your Session Expired!. Do you wish to continue?"))
{
window.setTimeout('checkIfContinue()', 5*1000); //start the timer again
sFlag = 0;
}
else
{
// logout
}
}
}
This is the query which i used to call the pop up after session time out. I need to close the browser when no responses given to the responses..
I believe that in this case you'll need to use some other than system dialog.
E.g. showing a DIV with the question and buttons, so you'll be able to close the window even with opened "dialog".
In jquery, there are plugins for this kind of dialogs like Jquery UI, or select on of theese:
http://choosedaily.com/1178/15-jquery-popup-modal-dialog-plugins-tutorials/
Also remember, that the browser window can be closed by script only when it was opened by the script. Otherwise the function window.Close(); will ask the user about closing.
So I've been looking around for hours, testing multiple versions, testing some of my own theories and I just can't seem to get it working.
What I'm trying to do is use alert or confirm (or whatever works) so popup a dialog when a user tries to navigate away from a purchase form. I just want to ask them "Hey, instead of leaving, why not get a free consultation?" and redirect the user to the "Free Consultation" form.
This is what I have so far and I'm just not getting the right results.
$(window).bind('beforeunload', function(){
var pop = confirm('Are you sure you want to leave? Why not get a FREE consultation?');
if (pop) {
window.location.href('http://www.mydomain/free-consultation/');
} else {
// bye bye
}
});
$("form").submit(function() {
$(window).unbind("beforeunload");
});
This is showing confirm dialog to user, want to stay or leave page. Not exactly what you looking for but maybe it will be useful for start.
function setDirtyFlag() {
needToConfirm = true; //Call this function if some changes is made to the web page and requires an alert
// Of-course you could call this is Keypress event of a text box or so...
}
function releaseDirtyFlag() {
needToConfirm = false; //Call this function if dosent requires an alert.
//this could be called when save button is clicked
}
window.onbeforeunload = confirmExit;
function confirmExit() {
if (needToConfirm)
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
Script taken from http://forums.devarticles.com/showpost.php?p=156884&postcount=18
Instead of using the beforeunload and alert(), I decided to check whether or not the users mouse has left the document. See code below:
$(document).bind('mouseleave', function(event) {
// show an unobtrusive modal
});
Not sure whether it will help.
You need to stop the propagation before showing the Confirm / Alert.
Please refer http://jonathonhill.net/2011-03-04/catching-the-javascript-beforeunload-event-the-cross-browser-way/
Look at the last comment.
Try this:
window.onunload = redirurl;
function redirurl() {
alert('Check this Page');
window.location.href('http://www.google.com');
}
Is it possible to block users from closing the window using the exit button [X]? I am actually providing a close button in the page for the users to close the window.Basically what I'm trying to do is to force the users to fill the form and submit it. I don't want them to close the window till they have submitted it.
I really appreciate your comments, I'm not thinking of hosting on any commercial website. Its an internal thing, we are actually getting all the staff to participate in this survey we have designed....
I know its not the right way but I was wondering if there was a solution to the problem we have got here...
Take a look at onBeforeUnload.
It wont force someone to stay but it will prompt them asking them whether they really want to leave, which is probably the best cross browser solution you can manage. (Similar to this site if you attempt to leave mid-answer.)
<script language="JavaScript">
window.onbeforeunload = confirmExit;
function confirmExit() {
return "You have attempted to leave this page. Are you sure?";
}
</script>
Edit: Most browsers no longer allow a custom message for onbeforeunload.
See this bug report from the 18th of February, 2016.
onbeforeunload dialogs are used for two things on the Modern Web:
Preventing users from inadvertently losing data.
Scamming users.
In an attempt to restrict their use for the latter while not stopping the former, we are going to not display the string provided by the webpage. Instead, we are going to use a generic string.
Firefox already does this[...]
If you don't want to display popup for all event you can add conditions like
window.onbeforeunload = confirmExit;
function confirmExit() {
if (isAnyTaskInProgress) {
return "Some task is in progress. Are you sure, you want to close?";
}
}
This works fine for me
What will you do when a user hits ALT + F4 or closes it from Task Manager
Why don't you keep track if they did not complete it in a cookie or the DB and when they visit next time just bring the same screen back...:BTW..you haven't finished filling this form out..."
Of course if you were around before the dotcom bust you would remember porn storms, where if you closed 1 window 15 others would open..so yes there is code that will detect a window closing but if you hit ALT + F4 twice it will close the child and the parent (if it was a popup)
This will pop a dialog asking the user if he really wants to close or stay, with a message.
var message = "You have not filled out the form.";
window.onbeforeunload = function(event) {
var e = e || window.event;
if (e) {
e.returnValue = message;
}
return message;
};
You can then unset it before the form gets submitted or something else with
window.onbeforeunload = null;
Keep in mind that this is extremely annoying. If you are trying to force your users to fill out a form that they don't want to fill out, then you will fail: they will find a way to close the window and never come back to your mean website.
How about that?
function internalHandler(e) {
e.preventDefault(); // required in some browsers
e.returnValue = ""; // required in some browsers
return "Custom message to show to the user"; // only works in old browsers
}
if (window.addEventListener) {
window.addEventListener('beforeunload', internalHandler, true);
} else if (window.attachEvent) {
window.attachEvent('onbeforeunload', internalHandler);
}
If your sending out an internal survey that requires 100% participation from your company's employees, then a better route would be to just have the form keep track of the responders ID/Username/email etc. Every few days or so just send a nice little email reminder to those in your organization to complete the survey...you could probably even automate this.
It's poor practice to force the user to do something they don't necessarily want to do. You can't ever really prevent them from closing the browser.
You can achieve a similar effect, though, by making a div on your current web page to layer over top the rest of your controls so your form is the only thing accessible.
Well you can use the window.onclose event and return false in the event handler.
function closedWin() {
confirm("close ?");
return false; /* which will not allow to close the window */
}
if(window.addEventListener) {
window.addEventListener("close", closedWin, false);
}
window.onclose = closedWin;
Code was taken from this site.
In the other hand, if they force the closing (by using task manager or something in those lines) you cannot do anything about it.