简体   繁体   English

如何使用Javascript或Jquery获取网站图标/ Apple-touch图标和网页标题?

[英]How to get favicon icon/ Apple-touch icon and title of a web page using Javascript or Jquery?

I can insert a whole web page in a div or an IFrame as: 我可以将整个网页插入divIFrame如下所示:

<iframe src="http://www.stackoverflow.com" id="iframe" scrolling="no"></iframe>

But I need only icon and title for Iframe . 但是我只需要Iframe图标和标题。

I have no idea how to get only these items favicon icon / Apple-touch-icon and title of a website. 我不知道如何仅获取这些项目favicon icon / Apple-touch-icon和网站title

eg www.stackoverflow.com , I need only its title and favicon icon / Apple-touch-icon . 例如www.stackoverflow.com ,我只需要其titlefavicon icon / Apple-touch-icon Is there any plugin or any parser that can parse the HTML of a web page and return these? 是否有任何插件或解析器可以解析网页的HTML并将其返回? Any help is appreciated. 任何帮助表示赞赏。

See "How can I get the title of a webpage given the url (an external url) using JQuery/JS" for getting the title. 有关获取标题的信息,请参见“如何使用JQuery / JS获得给定URL(外部URL)的网页标题”。 A similar technique should extract the favicon -- just look for <link rel="shortcut-icon"> instead of looking for <title> . 类似的技术应该提取图标,只需查找<link rel="shortcut-icon">而不是<title>

Note though that you're potentially going to run into cross-site scripting issues. 请注意,尽管您可能会遇到跨站点脚本问题。 See "How can I access iFrame elements with Javascript?" 请参阅“如何使用Javascript访问iFrame元素?” and "How to expose IFrame's DOM using jQuery?" “如何使用jQuery公开IFrame的DOM?” for an iframe approach. 适用于iframe方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM