-2

I have a html script that I embedded in the head of an HTML page that essentially sends page hit counts to a hosted server. When I host this page on Google Drive or any other hosting service, the page works fine and sends usage statics. When I put the file on my local machine and simply open it up on a browser it does not. Why?

FYI, I know this does not work, I am at a loss for the correct explanation.

jomille
  • 405
  • 12
  • 24

2 Answers2

3

XHR requests and many other features do not work for pages hosted via the file:// protocol. See Allow Google Chrome to use XMLHttpRequest to load a URL from a local file.

Community
  • 1
  • 1
dangerChihuahua007
  • 20,299
  • 35
  • 117
  • 206
0

It won't work in Chrome because of their security model. You can just setup a local server using live reload, browser sync or wamp then it'll work just fine. If u don't wanna mess up so much then I recommend u using prepros It's gives u a simple server with live reload and so many other things. it's free but there's a paid version too. Enjoy!

https://prepros.io/

Wadu
  • 107
  • 1
  • 12