简体   繁体   English

JS在弹出窗口中不起作用

[英]JS not working in popup window

chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('testcb.html', {
'bounds': {
  'width': 1240,
  'height': 720
    }
  });
}); 

That opens 那打开

<script type="text/javascript" src="libs/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="cb.js"></script>

<link rel="stylesheet" type="text/css" href="css/design.css"/>
<link rel="icon" type="image/png" href="favicon.png"/>

The java script does not work whatsoever. Java脚本无法正常运行。 I'm entirely new at making extensions/apps. 我是制作扩展程序/应用程序的新手。 And full explanation is needed. 并且需要完整的解释。

I realize this post is quite old, but I figure some input might help for anyone having troubles with this still. 我意识到这篇文章已经很老了,但是我认为一些输入可能会对仍然对此有疑问的任何人有所帮助。

There are actually a few different reasons this could be happening. 实际上,可能有几种不同的原因。

This could possibly be due to security measures that are built into your browser (Chrome in this case) that block Javascript scripts from loading/running. 这可能是由于浏览器(在本例中为Chrome)内置的安全措施阻止了Javascript脚本的加载/运行。

Another possibility may be that there are errors in your JS. 另一种可能是您的JS中有错误。 A quick and easy way to check is to use jsfiddle.net 一种快速简便的检查方法是使用jsfiddle.net

If you are still not getting anywhere something that usually helps me is to put the JS code directly inside a script tag in the html code: 如果您仍然找不到任何东西,通常可以帮助我的就是将JS代码直接放在html代码的script标签内:

<html>
<head>
    <script>
        // JS code here
    </script>
    <link rel="stylesheet" type="text/css" href="css/design.css"/>
    <link rel="icon" type="image/png" href="favicon.png"/>
</head>
<body>
</body>
</html>

Hopefully something here can give you some results, or a direction to head in! 希望这里有什么可以给您一些结果,或者是一个前进的方向!

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

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