JavaScript / PHP: Page Redirect

0

Good evening, I'm a complete beginner in web development, and after several google searches, I could not get a satisfactory answer. I am using the window.location.href command to redirect the pages of my system, however as they are in localhost, I am just using basic paths, for example: window.location.href="../pages/pagina.php"; or even window.location.href="pagina.php" (when they are in the same directory).

My question is this: when uploading to a web server, is this a problem? I would need to put the full path, like "http: // ..."?
Thank you for your attention.

    
asked by anonymous 30.06.2015 / 01:38

1 answer

2

No, the only situation that can be problematic is if you are specifying the path from the start , example window.location.href = http://localhost/pagina .

While you use ../ (back directory) or by specifying a direct page (no bar at the beginning) it will be relative to current url .

Example:

  • Current URL: link

    • window.location.href="../pages/pagina.php"; results in link
  • Current URL: link

    • window.location.href="pagina.php" results in link
30.06.2015 / 01:43