我已经构建了一个 chrome 扩展,它只是在弹出窗口中显示一些 HTML。我使用基础框架来显示表格和 jQuery 来操作 DOM
JQuery 和 Foundation 都下载到扩展并包含在 HTML 中。
当我在弹出窗口已经打开的情况下尝试更新表格时,我没有看到弹出窗口中的更改(例如 $('p').text("new text") ) - 但在元素部分Chrome Dev 工具的文本被更改。
此外,我在表格行上的 CSS 悬停效果仅显示在三个表格中的上面两个。
这是正常的事情吗?当我在单独的选项卡中查看 popup.html 时,我没有这些问题。
DOM 多久更新一次?我怎样才能控制它何时发生?
这是我的 popup.html:
<script type="text/javascript" src="../../js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../../js/what-input.js"></script>
<script type="text/javascript" src="../../js/foundation.min.js"></script>
<link href="../../css/foundation.min.css" rel="stylesheet">
<table class="hover unstriped">
<thead>
<tr>
<th width="200">Table Header</th>
<th>Table Header</th>
<th width="150">Table Header</th>
<th width="150">Table Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Content</td>
<td>Content Goes Here</td>
<td>Content Goes Here</td>
</tr>
</tbody>
</table>
<table class="hover unstriped">
<thead>
<tr>
<th …Run Code Online (Sandbox Code Playgroud) 我一直在尝试让 chrome.identity.launchWebAuthFlow 与我的 Chrome 扩展程序一起使用以访问 Google 的 OAuth Flow(不,我不想使用 getAuthToken)。我遵循了这个问题中列出的实现。
这些是我进行设置的步骤:
我已经在我的 background.js 文件中实现了这段代码
var auth_url = 'https://accounts.google.com/o/oauth2/auth';
var client_id = '<client_id from Cloud Console>';
var redirect_url = chrome.identity.getRedirectURL("oauth2");
var auth_params = {
client_id: client_id,
redirect_uri: redirect_url,
response_type: 'token',
scope: 'profile'
};
var params = Object.keys(auth_params).map(function(k) {
return encodeURIComponent(k) + '=' + encodeURIComponent(auth_params[k])}).join('&')
auth_url += '?' + params;
console.log(redirect_url);
console.log(auth_url);
chrome.identity.launchWebAuthFlow({url: auth_url, …Run Code Online (Sandbox Code Playgroud)