Facebook - Reload iframe without show confirm diaglog - javascript

I want to reload my webpage in an iframe (location.reload();) but Facebook always show a confirm dialog. I want to prevent this dialog from showing. Thank you.

You need to first redirect the user to any page via GET. That is a safety mechanism implemented into the browser and can not be disabled via JS.

I now use parent.location.href instead of location.reload();

Related

JavaScript redirect user to new page

I am working on a web app using Firebase and Vanilla JavaScript. Let's say I have home page index.html, when user clicks to sign in, a popup appears where he will enter details. Since he signs in it means the URL should be localhost:5000/signin. Is it possible to do it with JavaScript from frontend or is there a need to add Node.js to redirect user respectively.
I am confused how this works and would appreciate if someone could explain how should I approach this.
You can change the url without changing or reloading the page in modern browsers.
window.history.pushState({}, 'Signin', '/signin');
Or you can use replaceState since you are using modal, however it will break back button functionality.
Please look at pushState
This will work:
<script>
function signin() {
window.open("/signin", "_blank", "width=500,height=300")
}
</script>
You can change width and height to your sign-in page width and height. Also, you can add some other properties to your popup. For more information visit https://www.w3schools.com/jsref/met_win_open.asp
This also might be helpful if you want to make your page maximized How to open maximized window with Javascript?

How can I disable the saving bookmark function for specific page just via the html code?

the requeirment is that I want to avoid the specific web page to save to bookmark,
and is there someway to acheive this funcion just use some code, maybe add or js code . thanks
The answer is no, the user can always bookmark a page as this is browser function, but you can use sessions. Then make sure that any request for a page
must have an active session id or it returns an error or redirects to the home page. The user can bookmark the page but the bookmarks will then only work for a short time (until the session expires). This also has the added benefit of
making the site impossible to index by search engines.
The closest you're going to get is if you open another window using JavaScript as you can control whether the menubar and toolbar are displayed.
window.open(
"https://www.google.com/",
"Google",
"resizable,scrollbars,status");
However, this is likely going to be blocked by their popup blocker.

Javascript: Refresh parent page without entirely reloading

After a user has logged in via a fancybox (javascript) popup I wish to reload the parent page so they can access the logged in features.
Currently I am doing this with:
Continue
This works great, but the only issue is that it completely reloads the entire page: redownloads all the css & javascipt, etc.
All I want to do is reload the page normally, not a full refresh. How can I achieve this?
(I do not know the exact URL because the login can be done from any page via the fancybox, so I can't hardcode the URL.)
Another way of reloading the page i have seen in the facebook graph api is the following:
window.location = window.location
or in your case:
window.top.location = window.top.location
This solution reloads the page without trying to resend a POST request. Might be useful. for more information look at the following SO question.
Use:
location.replace(location.href.split('#')[0]);
The split on hash is required, otherwise an url with a hash will not be refreshed.
If you want to keep the previous load in browser history, use assign instead of replace.
href is not currently supported by Opera, according to MDN.

Back Button and Refresh with AJAX

I need a solution for the page refresh and the back button when using AJAX.
I'm using simple javascript for the AJAX implementation.
If anybody could send a code snippet I would be very grateful.
If you're using jQuery, there's the history plugin.
Here's a solution that I've used in some of my pages. Add this to pages that changes are made at.
window.onbeforeunload = function() {
window.name = "reloader";
}
this triggers when you leave those pages. You can also trigger it if there were changes made. So that it won't unnecessarily reload the page that needs reloading.
Then on pages that you want to get reloaded on after a the browser "back" use.
if (window.name == "reloader") {
window.name = "no";
location.reload();
}
this will trigger a reload on the page you need reloading to.
essentially, you need to use & monitor the hash portion of the url...
http://.../path?parms#hashpart
Whan you change the hash, iirc window.location.hash , it won't reload the page, but your ajax can monitor, and respond to it.
The onbeforeunload event can be useful to guard against refreshing but it fires if you navigate away or refresh. If you require that users login to the app you can always show a generic message advising against navigating away and refreshing. If users click your app log out button set a var to disable the warning. Could probably also make a 'Close' button that does the same thing.
Try PathJS it does not require jQuery or any other additional lib.

solution for popup page as modal

I was using window.showModalDialog() but doesn't work on all browsers.
People recommends me jquery, thickbox and also this contact Example
but the problem is when i submit the page, server will send me another page, and that page will replace my original page!
so actually it doesn't fulfill my requirement.
My requirement is on button click modal page should open and it can redirect to other page on same window without disturbing my original page and when I close My original page get reflections.
So is it possible?
Sounds like you need a simple html target="_blank" in the link to the other page.
http://www.htmlcodetutorial.com/linking/_A_TARGET_95y98y108y97y110y107y.html

Categories