Subscribe to edge.create in Page Tab - javascript

My Page Tab tells people to Like the page using the Like Button next to the title of the Page (directly above the iframe).
How do I subscribe to that event being clicked?
Javascript within the Page Tab does not work:
FB.Event.subscribe('edge.create',
function(response) {
alert('clicked like button');
}
);
Thanks!
EDIT: For now, I'm going with "you can't do it" as the answer...

edge.create is to be used with the Facebook Like Plugin. It won't fire when the like button next to the page name is clicked.
The page will get reloaded once the button is clicked.

Related

How to do two events in one link <a href..>: to external page (_blank) and to internal page (_self) in event onClick?

I have a link on site: <a href="https://paypal.com/..." title="Pay now on PayPal"...>Pay now</a>.
Needs to do next actions:
open onClick in new tab external page of PayPal (invoice),
open onClick in this tab internal page of next text about confirmation of payment.
Think its about using event(s) onClick in Pay now,
but I can`t find working example of this task. Please, help in this question to do working button.
Call this function on your button click:
function onClick() {
window.open("https://www.google.com", "_blank");
window.location.href = "https://www.facebook.com";
}

Know which button pressed led to this page

I have a menu with ~6 buttons, each that lead to the same page.
In that page, there is a drop down menu.
The purpose of the 6 buttons is that when one of those buttons is clicked, the page is redirected, and then the drop down menu opens to the correct tab.
However, all scripts are killed when a page is redirected, so I cant do something like this:
<body>
<a id="buttonID" onclick="GoToPage('buttonID')">All</a>
</body>
<script>
function GoToPage(buttonID){
redirect to page.html;
open menu to tab related to buttonID
}
</script>
Instead I would probably have to create a function that executes when the page loads, and then attempts to find from which button did it get there from, and opens the menu to the correct configuration based on that.
Should I use something like:
window.onload = ....
And how would I be able to pass which button redirected the page to this?
Opening the dropdown menu should be the responsibility of the destination page, not the source page. Since the server doesn't care about the dropdown menu state, send that information in the fragment identifier:
<a id="buttonID" href="page.html#all">All</a>
On the receiving end, you can retrieve the identifier with
document.addEventListener('DOMContentLoaded', (event) => {
let target = window.location.hash; // target = "#all"
// modify your menu as appropriate
});
The load event doesn't fire until the page has completely finished loading: images, stylesheets, everything. Modifying the dropdown menu doesn't require any of that, so use the DOMContentLoaded event instead. It fires when the HTML page has been loaded and parsed and is ready for DOM manipulation.

How to prevent user to go back with right click on back button?

When I press and hold the browser back button or just right click the back button I can go back pages. But I need to disable it. Is there any way to do that with javascript or jsp
Open A New Window without Back Button
browser-back-button-viralpatelThis one is very crude technique. But in some case it works like charm. All you have to do is to open the webpage in a new window. This window doesn’t have back button at all because we have hide the toolbar.
This technique does work in some case but user has still a workaround to navigate to previous page. Most of the browser have options of Back in context menu. Thus user can still right click on the page and click Back to go to previous page. We will shortly see the workaround for this issue also.
Following is the code to open webpage in a new window have no toolbar (Back/Next buttons).
window.open ("http://viralpatel.net/blogs/",
"mywindow","status=1,toolbar=0");
Also it is possible to disable the right click on any webpage using Javascript. Add following code in the webpage.
<body oncontextmenu="return false;">
Disable Back functionality using history.forward
This is another technique to disable the back functionality in any webpage. We can disable the back navigation by adding following code in the webpage. Now the catch here is that you have to add this code in all the pages where you want to avoid user to get back from previous page. For example user follows the navigation page1 -> page2. And you want to stop user from page2 to go back to page1. In this case all following code in page1.
<SCRIPT type="text/javascript">
window.history.forward();
function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"
onpageshow="if (event.persisted) noBack();" onunload="">
The above code will trigger history.forward event for page1. Thus if user presses Back button on page2, he will be sent to page1. But the history.forward code on page1 pushes the user back to page2. Thus user will not be able to go back from page1.
Warn User if Back is Pressed
You may want to warn user if Back button is pressed. This works in most of the cases. If you have some unsaved form data, you might want to trigger a warning message to user if Back button is pressed.
Following Javascript snippet will add a warning message in case Back button is pressed:
window.onbeforeunload = function() { return "You work will be lost.";
Reference
just use
window.onbeforeunload = function() { window.history.forward(1); };
or if u like to warning user
window.onbeforeunload = function() { return "Back button is not available!"; window.history.forward(1); };

How to handle when the x button is click on pop-up web page using Javascript?

I have a “pop-up” web page inherits from System.Web.UI.Page in a plug-in which is a part of a large web framework. The markup is inside <asp:Content> below. I need to perform some actions (updating the page behind) when the user clicks on “Close” button (id = _close) and when the user clicks on the ‘x’ button on the right corner of the page. My page is not displayed in the browser. I got the “onclick” (in the code behind) to work for “Close” button below, but I don’t know how to detect when the ‘x’ button is clicked. I tried on window.beforeunload and window.onclose, it doesn’t work. “Hello World” pops up when my web page opens and when I click “Close” (_close) button.
How do I handle for the click on the ‘x’ the same way when “_close” button is clicked?
<script language="javascript">
function doClose() { alert('Hello World!'); } window.onload = doClose(); // also tried with window.beforeunload </script>
You can execute the code on the opener. Write a method in opener and execute it from the pop-up window.
http://www.w3schools.com/jsref/prop_win_opener.asp

How to disable back,forward and Refresh functionality in browser?

Can anyone help me to disable browser back,forward, back button and right click menu functionality using JavaScript or JQuery? I have tried disabling the back button like this:
function disableBackButton() {
window.history.forward();
}
setTimeout("disableBackButton()", 0);
I have called this function in the Body onload event. I have a doubt that where we need to put this code in the Calling page or Called Page.Suppose i have two pages like this FirstPage.aspx and SecondPage.aspx. When I navigate from the First Page to Second Page when I click back button of the browser it should not go to FirstPage.aspx.
Have a look at A Thorough Examination of "Disabling the Back Button."

Categories