[英]JQuery - ScrollTop not working in Chrome Extension
I've been trying to figure this out for a while now, but I'm at my wit's end and have given up all hope. 我已经尝试了好一阵子了,但是我已经不知所措了,放弃了所有希望。
Here is my unpacked chrome extension: nexrem.com/test/extension-test2 - Copy.zip 这是我解压缩的Chrome扩展程序: nexrem.com/test/extension-test2-Copy.zip
Exhibit A: 展览A:
Exhibit B: Currently, the extension basically replaces the entirety of html on the page. 图表B:目前,该扩展程序基本上替代了页面上的整个html。
You will see the exact same page as when you ran just the test.html ;however, the jquery scrolling no longer works . 您将看到与仅运行test.html时完全相同的页面;但是, jQuery滚动不再起作用 。 I fail to understand why.
我不明白为什么。
If someone can explain this to me, assist in a solution or at least point in the right direction, I'd greatly appreciate it! 如果有人可以向我解释这一点,提供解决方案或至少指出正确的方向,我将不胜感激!
jQuery uses the browser's .innerHTML property to parse the retrieved document and insert it into the current document.
jQuery使用浏览器的.innerHTML属性解析检索到的文档并将其插入到当前文档中。 During this process, browsers often filter elements from the document such as
<html>
,<title>
, or<head>
elements.在此过程中,浏览器经常从文档中过滤元素,例如
<html>
,<title>
或<head>
元素。 As a result, the elements retrieved by.load()
may not be exactly the same as if the document were retrieved directly by the browser .结果,通过
.load()
检索的元素可能与通过浏览器直接检索的文档不完全相同 。
And after digging into your html code after you click the browser action, it seems the body tag is not included. 在单击浏览器操作后深入研究html代码后,似乎没有包含body标签。
You can use the following code instead load
您可以使用以下代码代替
load
var template = chrome.extension.getURL('template/test.html');
console.log(template);
$.get(template, function(data) {
document.open();
document.write(data);
document.close();
$.cache = {};
}, "text");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.