Make sure you're testing using the same node: Getting logs over a wide range can be quite taxing on the node you're pulling from, so not all public nodes will return them before they time out, or at all. If this turns out to be the problem, try reducing the range of the logs you're trying to fetch.
Also make sure web3 is loaded before you start to use it. Typically you want to check it's available after the page onload event, and only start using it then.
Finally, Metamask seems to have problems switching networks cleanly. After switching to the network you want to use, try closing all open Chrome windows (not just the window you're using Metamask in) and then open the browser again from scratch.