I am using a small function (first answer), that detects the browser. My setup is an apache server which is started with MAMP (Mac) on my local machine. The script is in a javascript file, which is loaded thru the header in html. But even if you test it in the chrome console, you have the same result.
Everything works well, when I use Chrome and localhost as address. (e.g. http://localhost:8888/index.html)
But as soon as I use my local ip address instead of localhost (e.g. http://192.168.0.1:8888/index.html), following javascript code returns false instead of true in Chrome:
!!window.chrome.runtime //it is undefined
And I have absolutely no idea, why this is so or how I can figure out the issue.
JS-Function | localhost:8888 | 192.168.0.1:8888
---------------------------------------------------------------
window.chrome.runtime | function | undefined
Why using local ip address? Because I want to show my colleagues sometimes something without deploying it.
I had a similar issue where I was trying to call
chrome.runtimefrom a website I was using to check if my extension was installed and it was coming back asundefined.The fix for me was to include the IP address in the
manifest.jsonfile of my extension under theexternally_connectablesection: