IE seems right, Chrome seems wrong
jessepollak.me
jessepollak.me
If url is null, return the empty string.
If port is the empty string, return host, serialized.
Return host, serialized, ":", and port concatenated.
So what is port in this case? That's defined at http://url.spec.whatwg.org/#port-state and the key step is: 2. If buffer is equal to url's scheme's default port,
set buffer to the empty string.
So IE is wrong and the MDN documentation is misleading. I've fixed the latter; can't do much about IE. ;)I wonder what the rationale behind this decision was. It seems like a pretty easy way to mess up people like me :D. Any ideas?
To me, it's like the type of the variable. The variable "port" should contain the port, not (port|"").
Return host, serialized, ":", and port concatenated.
...except if the port is an empty string, the process will terminate one step sooner: If port is the empty string, return host, serialized.
So there would be no trailing colon, in that case. parser.href = url;
causes the URL to be parsed. When URLs are parsed, the spec [1] says: 2. If buffer is equal to url's scheme's default port, set buffer to the empty string.
3. Set url's port to buffer.
Then the host is serialized. Here the spec says: 2. If port is the empty string, return host, serialized.
Since is is the empty string in the case where the port is the default port, no port should be appended on output, even if there was one there on input (serializing host doesn't magically append a port).I'm not really clear why this normalise function is needed at all though? Origin should be string comparable?
As a view it's a little mean perhaps, but one that anyone with experience of working with multiple browsers will be sympathetic to.
- https://code.google.com/p/jsuri/
- http://medialize.github.io/URI.js/
[1] http://stackoverflow.com/questions/956233/javascript-pathnam...
Updated answer here:
http://stackoverflow.com/questions/6944744/javascript-get-po...
I also created a JSFiddle to test here:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorE... writes:
URLUtils.host
Is a DOMString representing the hostname and port
(if it's not the default port) in the referenced URL.
But it implements https://developer.mozilla.org/en-US/docs/Web/API/URLUtils (experimental), which writes: URLUtils.host
Is a DOMString containing the host, that is the hostname,
a ':', and the port of the URL.If this was the front page of your app or service's website, then fine.
But I'm trying to read here. I cannot help but notice the colour change in the corner of my eye. It is endlessly distracting. In the end I used chrome dev tools to delete it so I could actually read the damn content.
This is a blog: I came here to read pages of text, not look at pretty lights.
(but yes, I have a plugin for that, but the rest of his site is great and readable, it's just that one thing)
One question: do you think slowing down the color change would make a difference? I started with a 10 second animation through 5 colors, but it's currently a 30 second one. I might experiment with making it 1 or 2 minutes to make it more unobtrusive. thoughts?
It is nowhere near as bad as a blog I read where the guy had a rainbow background explode out of his profile picture (that scrolled with you) every few seconds. I couldn't even get one paragraph through that one ;-)
It's not likely to pop up, but I noticed it right off the bat.
i..e, why couldn't you have written:
if (e.origin !== 'https://clef.io') {Checking Mozilla documentation, it makes it quite clear. "Is a DOMString representing the hostname and port (if it's not the default port) in the referenced URL."
https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorE...
So IE is getting it wrong? Edit: Other post points out experimental standard which IE may be adopting.
Its funny how standards evolve. Should we do things because they were declared standard? Or should we do things because they make sense?
In the case of the original post, it was IE vs Chrome. In the case I just brought up, it is Linux vs BSD with their implementation of POSIX.
The same story will continue to run as long as we expect different systems to run "similarly" based on a unified standard.
I believe Microsoft isn't following the same spec that every other browser is using.
I don't think you want users who; a) only use IE or b) believe in IE's infallability. Now that IE is not the dominant browser, we want IE to "work towards the specification". I'm really happy that IE9 and IE10 are so much more compatible than they were, but let's not go backwards!