Create a gist now

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>host of cloned 'a' element</title>
</head>
<body>
<script>
var a = document.createElement('a');
a.href = '';
a = a.cloneNode(false);
document.write('<p>a.host: ' + a.host + '<\/p>');
document.write('<p>location.host: ' + location.host + '<\/p>');
</script>
</body>
</html>
@nanto
Owner
nanto commented Nov 9, 2014

Open console and run the following code in any page.

var iframe = document.createElement('iframe');
iframe.src = 'http://bl.ocks.org/nanto/raw/695cfa663c066077e2ea/';
document.body.appendChild(iframe);

We expect a.host to be 'bl.ocks.org' but in IE it becomes a host of parent document.

@nanto
Owner
nanto commented Nov 9, 2014

This behavior of IE was referred to in http://d.hatena.ne.jp/monjudoh/20110207/1297071182 (written in Japanese).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment