Invite Friends lead them to a blank page - javascript

I implemented a FB Invite your Friends Button on one of my Facebook Apps. - the invite works well - the invited user gets the right message but when he clicks on it - it just lead to nowhere (a blank page).
How can I direct where this invite should lead to ?
Here is my invite code :
function invitefriends() {
FB.ui({method: 'apprequests',message: 'Einladen',data: '128', title: 'Lade Deine Freunde ein'}, requestCallback);
}
function requestCallback(response) {
//
}
Sorry - I searched already for a long time via google etc. but nothing solved my problem :(
edit
I found the problem - but now another problem occured.
The problem was that my index.php on my CANVAS URL was blank and only my tab.php (PAGE TAB URL) was the content. But since I am using a LIKE Gate (where people have to LIKE my page before they can use the app) - the invite leads always to the PLEASE LIKE site :/
is there still any chance I can choose where the invite should lead ?

No. You can not change where the invite sends the users. You can however have a simple redirect on your canvas page -
<script type="text/javascript">
top.location.href = "YOUR_TAB_PAGE_URL";
</script>

Related

javascript:history.back() OR homepage

I would like to add a button that will take a user back a page OR if a user used direct url to get to that page (so, .back() would take them back to google for example) - a user will be redirected to my homepage.
Looks like javascript:history:back() or history.go accept step attributes only (how many pages we can go back) and that is it. Will I have to tap into session or is there a way to do it with history object?
You can check the referrer url with document.referrer, to see what was the previous page where the user come from. It can be empty that means user come from direct link, or clicked the link from other app links skype etc...
In the example I used https://stackoverflow.com as an example, but you can make it more universal if you use with location.origin more info
As #Jonas W. Mentioned in the comments, be sure you check the full domain in the right position in the referrer, because of security reasons.
function go() {
if (document.referrer.indexOf("https://stackoverflow.com/") === 0) {
history.back();
} else {
window.location.href = "https://stackoverflow.com";
}
}
document.querySelector('button').addEventListener('click', go);
<button>back</button>

Facebook Javascript Inviting Friends

Basically, I have this piece of Javascript below:
javascript:var inputs = document.getElementsByClassName('uiButton _1sm');
for(var i=0; i<inputs.length;i++) {
inputs[i].click();
}
The user simply loads up a Facebook page, clicks on the 'See All' under "Invite Your Friends to Like This Page", scroll all the way down, then paste the above code into the console.
I was wondering if there's any way to modify this script to ensure that it automatically scrolls down to the bottom of the 'Friends List' before it starts inviting?
And maybe even a 0.3 second delay between each invite?
Thanks
You can scroll down using window.scrollTo(0,document.body.scrollHeight); before inviting all the the friends. The scrollTo() method scrolls the document to specified coordinates. So as you call this, the document will automatically scroll until it reaches the end. You need to use setInterval() to call this, and as soon as the end is reached you would need to clearInterval().
Have a look at my chrome extension on Github for inviting all friends to like any Facebook page here (Github). Also you can download my chrome extension from the google chrome store.
document.getElementsByClassName('headerTextLink')[0].click(); //Open Layer
window.setTimeout( function(){ //Timeout for 3 seconds
var inputs = document.getElementsByClassName('uiButton _1sm');
for(var i=0; i<inputs.length;i++) {
inputs[i].click();
}
}, 3000);
I hope, this is only for you. It's a dirty trick for inviting all friends at once.
You should think about whom you are sending an invitation. Otherwise it is spam.
Well , let this message. Here in this article I will share some way invite all friends to your Facebook fan page a click . We just need a simple script that automatically invite all your friends by clicking on a button to use . So , follow these simple steps and enjoy ..
Open your Facebook page , where you want to invite your friends.
Now simply navigate to the public to build > Invite option.
Now , a dialog box will be the option to invite all your friends
name.
Press F12 to open inspect element tab.
Go to the Console, tab and copy and paste the following script.
var inputs = document.getElementsByClassName('uiButton _1sm');
for(var i=0; i<inputs.length;i++)
{
inputs[i].click();
}
After the paste code above in the list of the console, then hit enter and see the magic ! all your friends will be invited to your Facebook page.

Selfclosing confirm box

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

Measure number of times users connect with Twitter

I'm using a connect with twitter button on my site, no an OAuth, but I wanted a way to accurately judge how many people pressed connect. There is a way to have a custom connect with twitter button like this. so i was thinking the button might bring you to a url to record the visit and then redirect right back to the main page. I'm not sure how or even if this idea will even work. How would I go a bout doing this?
as present on the twitter website a method like this one can enable custom signin
document.getElementById("signin-btn").onclick = function () {
T.signIn();
};
simply call a url from inside this method fto track the number of clicks to this button some thing like this.
document.getElementById("signin-btn").onclick = function () {
T.signIn();
$.get("UR_LINK");
};
now on the server side. because i dont know what tech ur r using psuedo code can be
On_Request()
{
clicked++;
saveTODataBaseClickedNumber(clicked);
}

Password protected hyper link with target=_blank

I have a hyper link like this :
<A Href=My_Java_Servlet?User_Action=Admin_Download_Records&User_Id=Admin onClick=\"Check_Password();\" target=_blank>Download Records</A>
When a user clicks on it, a password window will open, the user can try 3 times for the right password.
The Javascript looks like this :
<Script Language="JavaScript">
function Check_Password()
{
var testV=1;
var pass1=prompt('Password','');
while (testV<3)
{
if (!pass1) history.go(-1);
if (pass1=="password") { return true; }
testV+=1;
var pass1=prompt('Access Denied - Password Incorrect.','');
}
return "false";
}
</Script>
If user enters the wrong password 3 times, it's supposed to not do anything, but it still opens a new window and displays the protected info, how to fix the javascript or my html hyper link so only the right password will open a new target window, a wrong password will make it do nothing ?
Clientside JavaScript is perhaps the worst possible way to provide "security". Users can just view the source to see all of your passwords, or just disable JavaScript altogether. Do not do this.
Other people have answered your question with the true/false return value but here's some of the problems with the whole idea of checking the password in javascript on the client:
Your javascript source is freely readable by anyone downloading the page - thus showing them the password needed to view the page.
If they don't have javascript enabled then they'll just go straight to the page without getting the javascript prompt.
They could always just copy the link and paste it into their address bar to bypass the password protection. They could also just middle-click the link (which should open it in a new tab/window depending on their browser.)
Even on a private/intranet-only application this would be a laughable security method. :) Please consider re-desinging it so that the password is checked on the server-side portion (like when someone attempts to access the servlet it would render a password box and then post that password back to the server and then allow/deny access.)
You might to try returning false rather than "false"
However, you might be better off doing this kind of thing on the server, as I'd image all but novice users will know how to "copy link address" and paste this into their address bar.
Why are you returning "false" instead of false ?

Categories