jquery – 谷歌浏览器扩展程序 – 弹出页面无法正确显示

前端之家收集整理的这篇文章主要介绍了jquery – 谷歌浏览器扩展程序 – 弹出页面无法正确显示前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在努力创建一个Google Chrome扩展程序 – 在此扩展程序中,有一个使用Accordion-通过Jquery UI的弹出页面.

现在,我已经在manifest.json中正确定义了popup.html文件,并将jquery UI的“start”主题代码添加到popup.html文件中.

然而,当我点击工具栏中应该显示弹出窗口的按钮时,手风琴的所有部分都显示为打开 – 并且手风琴根本没有显示 – 我只能看到所有部分的纯文本手风琴.

下面是我的manifest.json–的代码

{
  "name": "Test","version": "1.0","manifest_version": 2,"content_scripts": [
     {
       "matches": ["<all_urls>"],"js": ["jquery-1.7.2-full.js","basicjs.js"]
     }
  ],"description": "The first extension that I made.","browser_action": {
    "default_icon": "icon.png","default_popup":   "popup.html"
  },"permissions": [
      "http://*/","https://*/"
  ],"background": {
      "scripts": ["background.js"]
  },"browser_action": {
      "default_icon": "images/anya_bl_32x32x32.png",// optional
      "default_title": "Test",// optional; shown in tooltip
      "default_popup": "popup.html"        // optional
 }
}

另外,下面给出了我的popup.html文件代码的一部分 –

<html>
<head>
<title> Anya Services Data Crawler Automated Data Retrieval App</title>
<style>
/*!
 * jQuery UI CSS Framework 1.8.21
 *  Below this is the entire code for the start theme's css file....
 .................................
</style>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
  <script type="text/javascript" src="jquery-ui-1.8.21.custom.min.js"></script>
   <script>
        $(function() {
    $( "#accordion" ).accordion({
        collapsible: true
    });
});
</script>
 </head>

 <body>

<div id="accordion">
<h3><a href="#">Section 1</a></h3>
<div>
    <p>Mauris mauris ante,blandit et,ultrices a,suscipit eget,quam. Integer ut neque. Vivamus nisi metus,molestie vel,gravida in,condimentum sit amet,nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p>
</div>
<h3><a href="#">Section 2</a></h3>
<div>
    <p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit,dolor at aliquet laoreet,mauris turpis porttitor velit,faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p>
</div>
<h3><a href="#">Section 3</a></h3>
<div>
    <p>Nam enim risus,molestie et,porta ac,aliquam ac,risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo,magna quis lacinia ornare,quam ante aliquam nisi,eu iaculis leo purus venenatis dui. </p>
    <ul>
        <li>List item one</li>
        <li>List item two</li>
        <li>List item three</li>
    </ul>
</div>
<h3><a href="#">Section 4</a></h3>
<div>
    <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra,per inceptos himenaeos. </p>
</div>
</div>


</body>
</html>

我在这做错了什么?我该如何解决这个错误

解决方法

指定 "manifest_version": 2时,将设置 default Content security policy restrictions.其中一个后果是不评估内联JavaScript.

no way启用内联Javascript.要使代码正常工作,请将其移至外部脚本文件并嵌入,如下所示:

<script src="popup.js"></script>

popup.js:

$(function() {
    $("#accordion").accordion({
        collapsible: true
    });
});
原文链接:https://www.f2er.com/jquery/181141.html

猜你在找的jQuery相关文章