I need to refresh a particular page say every 2 mins. But, only the <iframe> within it gets
refreshed. I tried: window.location, location.href and so on. I need to pass new parameters every time and reload the page. So, think, .reload might not work. Please help.
have you tried:
document.location.reload(true)
or
parent.document.location.reload(true);
You need to access the parent:
parent.location.href = 'blah.html'
Related
I have taken a text-box to input the content and after the input , I have created refresh() btn to refresh. My code is working fine. But the part is On the click of refresh() button , only the page should get refreshed , but my code is refreshing the complete window. I tried using $route.reload(), but it din't work properly. I browsed through some sites, but I din't got the appropriate result. I tried my best to do it. But hopefully, I couldn't continue further.
My plunker : https://plnkr.co/edit/0r7DXPWWtXmFYsHwY6Q3?p=preview
Here you can check it out.
Why you want reload the whole page? You can do just clear the fields instead of reload the whole page.
$scope.reloadPage = function(){
$scope.name = '';
}
or trigger your page load function or code
$scope.reloadPage = function(){
//You should call the function as what you did when the page load.
}
EDIT:
I know that functionality. But I have n number of text-fields. So its not an good practice to carry it
Then you should use with an object like $scope.objectname={textboxes1,2.....};
So you can easily clear the object like $scope.objectname={};
I have update your plunkr. please take a look that.
https://plnkr.co/edit/UxTNY1zgD4CrUEvERcHT?p=preview
I want to redirect from a.html to b.html with a parameter for example array c[],i used something like location.href = "b.html"; but when i write something like console.log(c[0].name); in my .js i got nothing after the redirection to b.html!
thanks in advance for your help :)
$(".btn").click(function(){
location.href = "b.html";
//.. push of some elemts to the array elements
// .. try to show elements in b.html with console.log() for example
});
As commented before, once you are redirected, you are literally on a new page. So everything you had before is unloaded. ( And your script which is supposed to execute after setting the location.href is stopped )
There are several ways to handle data into the next page, but by far the most easiest one would be to use query-parameter in your URI. Check that out:
https://en.wikipedia.org/wiki/Query_string
You are limited by the size of data, the data is somehow visible, and it could be easily hacked, though - but it seems you are quite at the start of something anyway.(?)
Does anyone know how to refresh the parent page and post value from child window in javascript/jquery?
I have using window.opener.location.reload();to refresh the parent page, but I have no idea how can I also passing the post value ?name=test&age=28 while refreshing the parent page.
try,
window.opener.location.href = window.opener.location.href + "?name=test&age=28"
This should reload the parent page with the added values.
You could set the window's href attribute.
e.g.
window.opener.location.href += "?name=test&age=28"
Depending on the browser you may or may not need to still include the reload code.
In my sample website, I was trying to redirect my page using javascript window.location.replace method. As I need to refresh the page, I used document.URL. It works well. But sometimes I noticed that it not working without giving any error. Finally I found that some links adds # in address bar and one of my javascript add a ? to the same. At that time the code window.location.replace(document.URL) wont execute. Is that due to the characters in the URL?
here is my function(sample)
function sample() {
alert(document.URL);
window.location.replace(document.URL);
}
the alert showing url like http://localhost/something/#?. and at this time it will not refresh the page.
Use any of these
location.reload();
window.location.reload();
window.location.href=window.location.href
You need to use location.reload(); instead.
I have drawn a chess board in a php page. Every piece is set as draggable, and every tile as droppable. Once a piece is dropped on a tile, I'd like to reload the php page so the board can be drawn anew along with new positions.
How can I do that: reloading the php page with javascript, without displaying a window asking for confirmation such as "To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier. ->Cancel; Resend" ?
Or perhaps there are better solutions?
If you want to avoid having refresh reporting data (for any reason, including the user clicking the reload button) then use the POST-REDIRECT-GET pattern (http://en.wikipedia.org/wiki/Post/Redirect/Get). Read that, it will explain what to do.
Quick solution: you could try:
window.location.reload(true); //true sets request type to GET
Use GET, instead of POST and the dialog box you are getting will go away.
Good luck!
Make use of
window.location.reload();
will refresh automatically
<script>
var timer = null;
function auto_reload()
{
window.location = 'http://domain.com/page.php'; //your page location
}
</script>
<!-- Reload page every 10 seconds. -->
<body onload="timer = setTimeout('auto_reload()',10000);">
reference http://davidwalsh.name/automatically-refresh-page-javascript-meta-tags