【发布时间】:2012-05-17 02:17:09
【问题描述】:
我在下面找到了用于创建 iframe 的 sn-p:
我只想在 http://www.host.com 加载文本内容并使用 display:none 使 iframe 不可见
背景:
我需要一种有效的方法来解析网站图标的位置。并非所有站点都有默认位置。例如<link rel="SHORTCUT ICON" href="../images/logo_small.ico" />。
因此,我只需要文本内容。 PHP 有一个函数可以做到这一点(file_get_contents),但我想在客户端做。
这里是mdn documentation on iframe
对于服务器端 PHP,请使用 file_get_contents.
function makeFrame() {
ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", "http://www.host.com");
ifrm.style.width = 640+"px";
ifrm.style.height = 480+"px";
document.body.appendChild(ifrm);
}
美味书签示例:
javascript:(function()
{
f='http://www.delicious.com/save?url='+encodeURIComponent(window.location.href)+
'&title='+encodeURIComponent(document.title)+'¬es='+
encodeURIComponent(''+
(window.getSelection?window.getSelection():document.getSelection?
document.getSelection():document.selection.createRange().text))+'&v=6&';
a=function()
{
if(!window.open(f+'noui=1&jump=doclose','deliciousuiv6','location=1,links=0,scrollbars=0,to
olbar=0,width=710,height=660'))
{
location.href=f+'jump=yes'
}
};
if(/Firefox/.test(navigator.userAgent))
{
setTimeout(a,0);
}
else
{
a();
}
})()
【问题讨论】:
-
...你考虑过使用 DOM 吗?
-
“使用 DOM”是什么意思?
标签: php javascript iframe