开发者

How to create infinit Iframe containing itself page?

So I try

document.write('<iframe src='+ location.href + ' width="468" height="60" ></iframe>');

But it seems not to be working at chrome...

This also does not work

<div id="main"></div>
function $(id)
{
  return document.getElementById(id);
}
  var div = document.createElement("iframe");
div.setAttribute("src", location.href);
div.setAttribute("width", "500");
div.setAttribute("height", "90");
$('main').appendChild(div); 
document.write(location.href);

And this does not work

function $(id)
{
  return document.getElementById(id);
}
document.write('<div id="main"></div>');
  var div = document.createElement("iframe");
div.setAttribute("src", location.href);
div.setAttribute("width", "500");
div.setAttribute("height", "90");
$('main').appendChild(div); 
document.w开发者_Go百科rite(location.href);


  <iframe src="about:blank" onload="if(!this.t){this.t=1; var href=location.href.replace(/[\?\&]inf\=.+/i,''); href += href.indexOf('?') > -1 ? '&inf=' : '?inf='; this.src = href + Math.random();}"></iframe>

I tried on chrome.. seems ok :)

Edit

appended some regex for safe url


Looks like most browsers block that option, which is probably a good idea.

Tested with the code:

<iframe src="."></iframe>

On Chrome, I get this page:

How to create infinit Iframe containing itself page?

http://jsbin.com/epimi4/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜