The "null" URL

Some time ago I came across the need for a no-op URL that would do nothing when loaded. The original use-case was an <iframe> that needed to have its [src] attribute cleared to avoid an obscure browser bug.

Another developer had originally used http://google.com, however google is not an acceptable "null" url. http://example.com is another poor choice.

I had considered using an empty source:

iframe.src = '';

which for an <iframe> would work, however as a general-purpose "null" URL it has issues.

For example, if you set the location.href to '' you will reload the current page, rather than clearing it.

javascript:void(0) won't work either, as it attempts to execute javascript in the context of whatever page it's being called in.

A good choice for a "null" url is about:blank.

The default behavior for browsers navigating to about:blank is to create an empty document in the current site context, without needing to make any web requests for the content, because there isn't any content.