0

I want to submit a form when entering a specific address on the url bar manually , is it possible? something like this

if(urlbar== "mylink.com/admin" && event.keyCode === 13)
    {
       myform.submit();
    }
  • Do you mean when the user manually pastes in a different address into their browser and navigates away from your page? – Andy Ray May 30 '18 at 15:54

2 Answers2

0

You cannot detect events in the browser's address bar.

You cannot detect the URL the user is about to navigate to if the navigation is caused by something outside the page (e.g. you could use a click event on an a element and then read it's href but you could not use onbeforeunload and get the URL typed into the address bar).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
-1

Can use an interval.

 setInterval(function() {
      if(location.href == "mylink.com/admin") {
          myform.submit();
      }
  }, 1000);

https://stackoverflow.com/a/1930942/3093731

Andrew
  • 18,680
  • 13
  • 103
  • 118