How does browser detect embedded web content from a HTML page?

北城余情 提交于 2020-02-05 06:23:05

问题


Once a browser gets the main html page, how does it know which are the embedded content should be request again from web server, and which are only external links? Is it based on type of tags, e.g ?

If so, could someone give me a reference of what these tags are?

Thanks.


回答1:


The HTML5 spec defines the element category "Embedded content":

Embedded content is content that imports another resource into the document, or content from another vocabulary that is inserted into the document.

It lists the following elements:

  • audio
  • canvas
  • embed
  • iframe
  • img
  • math
  • object
  • svg
  • video

Elements like link or script (both in Metadata category) can also refer to other ressources that user-agents (browsers, screen-readers, …) are free to link to or include or do whatever they want to do with it. For example, browsers like Firefox or Chromium will (by default) load and "apply" CSS that is linked within the link element, that has the rel value = stylesheet. Browsers like Lynx or w3m won't do that. They simply ignore that link.


For link, HTML5 states which link types "are links to resources that are to be used to augment the current document, generally automatically processed by the user agent":

Two categories of links can be created using the link element: Links to external resources and hyperlinks. The link types section defines whether a particular link type is an external resource or a hyperlink.


Maybe also consider the style attribute (for inline CSS), which could include a background-image url.




回答2:


Yes, the tags help browser identify the resources to load. After downloading/retrieving the content the browser determines what to do with the content based on the content-type header in the response.



来源:https://stackoverflow.com/questions/12320239/how-does-browser-detect-embedded-web-content-from-a-html-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!