简体   繁体   English

JavaScript 检索的 Div 未显示在源代码中

[英]Div retrieved by JavaScript not showing up in source code

I am retrieving a div like so:我正在检索这样的 div:

window.onload=  function get_all(){
  function get_header(){
        $('#main_header').load('/Head_footer.php #head_main');
    }

    $(function() {
        get_header();
    }); };

However the source code is not show what is in the div, but it is shown properly in the webpage.然而,源代码没有显示 div 中的内容,但它在网页中正确显示。

This is what the source code shows:这是源代码显示的内容:

 <div id="main_header"><script type="text/javascript">
    window.onload=  function get_all(){
      function get_header(){
            $('#main_header').load('/Head_footer.php #head_main');
        }
        $(function() {
            get_header();
        });
}; </script>
    </div>

What I want is that the source code shows what is in the div.我想要的是源代码显示了 div 中的内容。 Is there a way to do that?有没有办法做到这一点? Any help welcome.欢迎任何帮助。

The reason why I ask this is because google doesn't read the mark up of the structured data within this div.我问这个的原因是因为谷歌没有读取这个 div 中结构化数据的标记。 As it is not shown in the source code因为它没有在源代码中显示

In view source you can only see the things which are already existed.在查看源中你只能看到已经存在的东西。 You cannot see dynamic content but if you want to inspect those dynamic content then use Developer tools of your browser您看不到动态内容,但如果您想检查这些动态内容,请使用浏览器的开发人员工具

For the Firefox Right click on page and select Inspect Element option对于 Firefox 右键单击​​页面并选择检查元素选项

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

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