Me pregunto cómo actualizar / recargar una página (o incluso un div específico) una vez (!) Usando jQuery.
Lo ideal sería que de una manera correcta después de la DOM structureestá disponible (cf. onloadcaso) y no afectar negativamente back buttono bookmarkfuncionalidad.
Tenga en cuenta: replace() no está permitido debido a restricciones de terceros.

Respuestas:
Muy bien, creo que tengo lo que estás pidiendo. Prueba esto
if(window.top==window) { // You're not in a frame, so you reload the site. window.setTimeout('location.reload()', 3000); //Reloads after three seconds } else { //You're inside a frame, so you stop reloading. }Si es una vez, hazlo
$('#div-id').triggerevent(function(){ $('#div-id').html(newContent); });Si es periódicamente
function updateDiv(){ //Get new content through Ajax ... $('#div-id').html(newContent); } setInterval(updateDiv, 5000); // That's five secondsPor lo tanto, cada cinco segundos se actualizará el contenido div # div-id. Mejor que refrescar toda la página.
fuente
Para recargar, puede intentar esto:
window.location.reload(true);fuente
window.location.href=window.location.href;fuente
Utilizar esta:
<script type="text/javascript"> $(document).ready(function(){ // Check if the current URL contains '#' if(document.URL.indexOf("#")==-1) { // Set the URL to whatever it was plus "#". url = document.URL+"#"; location = "#"; //Reload the page location.reload(true); } }); </script>Debido a la
ifcondición, la página se recargará solo una vez.fuente
$('#div-id').click(function(){ location.reload(); });Ésta es la sintaxis correcta.
$('#div-id').html(newContent); //This doesnt workfuente
No tiene una función de actualización de jQuery, porque esto es lo básico de JavaScript.
Prueba esto:
<body onload="if (location.href.indexOf('reload')==-1) location.replace(location.href+'?reload');">fuente
Utilizar:
<html> <head> <title>Reload (Refresh) Page Using Jquery</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $('#reload').click(function() { window.location.reload(); }); }); </script> </head> <body> <button id="reload" >Reload (Refresh) Page Using</button> </body> </html>fuente
Agregue esto a la parte superior de su archivo y el sitio se actualizará cada 30 segundos.
<script type="text/javascript"> window.onload = Refresh; function Refresh() { setTimeout("refreshPage();", 30000); } function refreshPage() { window.location = location.href; } </script>Otro es: agregue la etiqueta de la cabeza
<meta http-equiv="refresh" content="30">fuente
- location = location - location = location.href - location = window.location - location = self.location - location = window.location.href - location = self.location.href - location = location['href'] - location = window['location'] - location = window['location'].href - location = window['location']['href']No necesitas jQuery para esto. Puedes hacerlo con JavaScript.
fuente
Usa esto en su lugar
function timedRefresh(timeoutPeriod) { setTimeout("location.reload(true);",timeoutPeriod); } <a href="javascript:timedRefresh(2000)">image</a>fuente
Prueba este código:
$('#iframe').attr('src', $('#iframe').attr('src'));fuente
Prueba esto:
<input type="button" value="Reload" onClick="history.go(0)">fuente
Para actualizar la página con javascript, simplemente puede usar:
location.reload();fuente
Es posible que deba usar la
thisreferencia junto conlocation.reload()verificar esto, funcionará.this.location.reload();fuente