源代码和 DOM 有什么区别? [英] What is the difference between source code and DOM?

查看:25
本文介绍了源代码和 DOM 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 在我的应用中,我想处理 Google 翻译定义,例如歌曲"一词的定义

  • 当我检查返回的 http 消息时,它不包含短诗"表达.

  • 但在 Safari 的 DOM 树视图中,我可以看到短诗"信息.

  • 这是因为在加载页面后,一些 JavaScript 代码做了一些魔法?你如何在 iOS 应用中获得 DOM 树?UIWebView 可以做到这么神奇?
  • This is because after loading page some JavaScript code do some magic? How would you get DOM tree in an iOS app? UIWebView can do such a magic?

推荐答案

页面的源代码和页面的 DOM 的概念相似,但又不同.源是未经任何客户端脚本掺杂的原始 HTML.它是 HTTP 请求对服务器的直接响应.另一方面,DOM 是相同的 HTML 结构,已被 JavaScript 修改.

The notions between a page's source and a page's DOM are similar, but different. The source is the raw HTML that is unadulterated by any client-side scripts. It is the direct response of the HTTP request to the server. The DOM, on the other hand, is the same HTML structure that has been modified by JavaScript.

源代码读取页面的 HTML 就像您在文本编辑器中打开它一样.源代码会在加载任何 JavaScript 之前反映您的 HTML 结构.虽然无法编辑内容,但查看浏览器从服务器接收的 HTML 很有用.

Source Code reads the page's HTML as if you opened it in a text editor. The source code reflects your HTML structure before any JavaScript is loaded. While the contents can’t be edited, it’s useful to see the HTML the browser receives from the server.

https://developer.apple.com/library/mac/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/ResourcesandtheDOM/ResourcesandtheDOM.html

尝试阅读有关 API,我认为有用于翻译和东西的 API

Try to read about API, I think there are API's for translate and stuff

这篇关于源代码和 DOM 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆