Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 3
    @Randomblue What about it? You will get about://. However, I am curious to know, what would be the use case for about:blank? I am not sure if any browser injects plugin resources in about:blank, but seems like that could be the only use case.
    – Shef
    Commented Sep 2, 2012 at 6:27
  • 3
    This doesn't work at all if you have a URL string, right? (i.e. you need to be at location for this to work)
    – Nick T
    Commented Oct 5, 2015 at 22:57
  • 1
    Sorry for the late reply, @NickT. Yes, it does't do that. Please, use the nice solution provided by David for that.
    – Shef
    Commented Oct 7, 2015 at 16:37
  • 27
    Can't you use location.host instead of location.hostname + location.port?
    – c24w
    Commented Sep 20, 2016 at 14:28
  • 1
    Upvoting for hinting that location.protocol contains the colon. Commented Aug 30, 2019 at 11:25