basically i am checking if i am in the same url as the page
and i want to refresh the page only once,but whenever i try it keep refreshing infinitively

 place='/development/petersburg';
 var pathname=window.location.pathname;
    if((pathname==place)){

     window.location.reload();//reload the page
 }

help!! how can i limit this page to refresh only once if the condition is true?

Hi,
Try this, adding a #hash for first refresh, then, if no #hash in URL, make refresh

place = '/development/petersburg';
var pathname = window.location.pathname;
if((pathname == place)){
  if(window.location.hash == '') window.location = window.location + '#hashrl';    //reload the page
}

After refresh, the URL wil be: /development/petersburg#hashrl

seems like its what i need. but the $_GET method is PHP and am working on file.js ..what is the js way of doing this.

place='/development/petersburg';
 var pathname=window.location.pathname;
    if((pathname==place)){
    if($_GET['refresh'] != 'no'){
     window.location.reload();//reload the page
     }
 }
Member Avatar for diafol

Something using the location.hash ?

place='/development/petersburg';
 var pathname=window.location.pathname;
    if((pathname==place)){
    if(location.hash && location.hash != '#no'){
     window.location.reload();//reload the page
     }
 }

Thankx guys, its now working..i added the window.location.hash as both of you suggested.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.