Get code source of dynamically loaded HTML content (Chrome/Gmail)

三世轮回 提交于 2019-12-07 19:03:26

问题


I am trying to access the HTML code source of AJAX dynamically loaded content. How could I do it? For example on Gmail, I am trying to access the HTML code of a given email discussion's content (the different entries of a given email discussion) which is loaded only when I click on this email discussion's line in the main list. The code source I can access is only the one of the page initially loaded (the list of all email discussions). Any idea?


回答1:


Right-click on the page and select "Inspect Element". The element view is updated when JavaScript makes changes to the page, whereas the "View Source" view only shows content from when the page was loaded.




回答2:


If you right click -> "View Source", it will show you the contents of a reloaded version of the page you are on.

Using "Inspect element" (hotkey CTRL+SHIFT+i) in Chrome shows the source of the dynamic content.




回答3:


I think you want to bind event on the dom element that loaded after initial page load using ajax. If so then you can use jQuery library and you can use live method of jquery.

Here is a link for live method, you can check that.

http://api.jquery.com/live/

What you need Download jquery latest library (http://docs.jquery.com/Downloading_jQuery) and then include it in script within head or you can use cdn http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js

then do like following <script> $(document).ready(function(){ $("#ajax_dom_element_id").live('click_or_any_event',function(){ code snippet you wan dot }); }); </script>

I think it will be helpfull.



来源:https://stackoverflow.com/questions/9333889/get-code-source-of-dynamically-loaded-html-content-chrome-gmail

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