Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to quick-access the root of my website using window.open()?

Let's say I have a page located here in my website:

  • mywebiste.com/section1/slideshow/main/example.html

I'd like to use window.open() to access these pages in my website:

  • mywebsite.com/section2/index.html
  • mywebsite.com/section2/article1/gallery.html
  • mywebsite.com/login.php

These are just random examples, but I'm trying to point out that they are very far away from the example.html page, and I would have to use a lot of ../ and as such ending up with very long (and confusing) URLs.

I thought that there should be a way to directly access the root of the website, but still using relative URLs. (Like if a shortcut .../ or root/ existed and that could redirect you to the root).

Is this possible?

like image 751
Yonic Avatar asked Dec 08 '25 08:12

Yonic


1 Answers

Just to preface with a / should work.

window.open('/section2/index.html', ...); // etc
like image 166
Naftali Avatar answered Dec 09 '25 23:12

Naftali