简体   繁体   中英

Javascript Google Chrome Extension, Looking For Domain Name, Not APP ID

I tried to get the domain name using alert(document.domain); But i'm not getting the right domain when I have the app installed on my chrome extension tool bar and test it out in a site,

I keep getting "hiecjmnbal...(long value)" which I believe represents my google app's id.

I have added this in the manifest too

  "content_scripts": [
        {
        "js": ["inject.js"]

        }
  ],

alert(document.domain); is the only line of text inside inject.js .

I've also used window.top.location which shows the chrome extension url of: chrome-extension://hiecjmnbal...(long value)/popup.html

And I've incorporated this <script type="text/javascript" src="inject.js"> </script> into the main html file after popup.js

Any thoughts on why I'm not getting the correct domain url and only getting google chrome's extension URL?

Thanks!

你有没有尝试过:

alert(location.href);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM