0

I have a static page in the form of a puzzle, I want to use the argument "if else" so that my page can be viewed if the url of my page is clicked from the site I want. For example, simple.

if my result page is visited through this site.

https://example.com

so https://example.com/result can be seen.

however, if my page is visited through this site

https://example-2.com

or not through example.com site, or visit the example.com/result link directly without going through the https://example.com

so https://example.com/result Not showing anything.

Can I implement a system like this on my static page using only arguments if else jquery?

vhlan
  • 1
  • 2

1 Answers1

0

you can use

document.referrer

The Document.referrer property returns the URI of the page that linked to this page.(MDN)

you can do something like this

if (document.referrer != ""){
    if (new URLPattern(document.referrer).hostname === new URLPattern(window.location.origin).hostname){
        //show result 
    }
}
Himansa Eshan
  • 314
  • 6
  • 10