我想知道是否可以将 IFrame float 到浏览器之外? 是否可以将 IFrame 拖出浏览器?
我的想法是我的 html\js 应用程序就像一个任务栏,我希望 Iframe 能够拖到浏览器之外的其他程序的顶部。
谢谢, 多尔。
最佳答案
我见过的唯一可以做到这一点的应用程序是 AIR .也就是说,你可以做 edge detection如果您知道 URL,则在到达边缘时在新窗口中打开 iframe 内容
jsFiddle 和伴随 DEMO - 与往常一样,window.open 假设您允许来自网站的弹出窗口
使用 jQuery UI 可拖动:
$("#container").draggable({
drag: function(event, ui) {
var offsetXPos = parseInt( ui.offset.left );
var offsetYPos = parseInt( ui.offset.top );
$("#coord").text(offsetXPos+'x'+offsetYPos);
if (offsetXPos===0 || offsetYPos===0) { // be careful with <= since it may trigger many windows
$("#container").hide();
window.open('http://msn.com','_blank');
}
}
});
<div id="container">
<div id="handle">Drag me <span id="coord"></span></div>
<iframe src="http://msn.com/" frameborder=no></iframe>
</div>
</div>
#container { left:100px; top:100px; width:500px }
#handle { border:1px solid black; height:40px, width:100%; background-color:lightblue; cursor:move; pointer:move}
iframe { width:100%; border:0 }
关于javascript - 是否可以将 IFrame float 到浏览器之外?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8415634/