What is the difference between source code and DOM?

孤街浪徒 提交于 2019-12-10 21:44:11

问题


  • In my app I want to process Google Translate definitions, like definition for the word "song"

  • When I check returned http message, it does NOT contain the "short poem" expression.

  • But in DOM tree view in Safari I can see the "short poem" info.

  • 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?

回答1:


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.

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 Safari receives from the server.

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

Hope it helps you.

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



来源:https://stackoverflow.com/questions/29273391/what-is-the-difference-between-source-code-and-dom

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