当前位置: 动力学知识库 > 问答 > 编程问答 >

How to get body.scrollHeight in script injected of Chrome Extension?

问题描述:

Here are the list of my project's files.

index.html - main extension file

manifest.json

background.html

background.js

content.js

manifest.json

manifest.json

...

"content_scripts": [

{

"all_frames": false,

"js": [

"content.js"

],

"matches": [

"https://www.****.com/vsearch/*"

],

"run_at": "document_end"

}

]

content.js

...

console.log(document.body.scrollHeight);

I need to get scrollHeight of special site in content.js.

But when I load this extension, sometimes I got scrollHeight of index.html.

By watching content.js using Chrome Dev Tool, content.js injected correctly in special site.

How can I fix this issue?

分享给朋友:
您可能感兴趣的文章:
随机阅读: