有人可以解释这个代码不正确的地方吗
<script>
chrome.browserAction.onClicked.addListener(function(window) {
chrome.windows.onCreated.addListener(function(enumerated string ["popup"]) {
chrome.windows.create({'url': chrome.extension.getURL('redirect.html')}, function(window) {
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
我正在尝试实现这一点,当在新的弹出窗口上单击扩展时将加载.
我正在使用以下代码在Google Chrome扩展程序中打开弹出窗口,我的一个问题是,如何在用户屏幕的中心打开弹出窗口?
<script>
chrome.browserAction.onClicked.addListener(function() {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
chrome.windows.create({'url': 'redirect.html', 'type': 'popup', 'width': 440, 'height': 220, 'left': '+left+', 'top': '+top+', } , function(window) {
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
我也试过这个,结果没有运气.
<script>
chrome.browserAction.onClicked.addListener(function() {
chrome.windows.create({'url': 'redirect.html', 'type': 'popup', 'width': 440, 'height': 220, 'left': (screen.width/2)-(w/2), 'top': (screen.height/2)-(h/2), } , function(window) {
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 我发现(从这个问题 - 隐藏div,如果屏幕小于一定宽度)这段编码
$(document).ready(function () {
if (screen.width < 1024) {
$("#floatdiv").hide();
}
else {
$("#floatdiv").show();
}
});
Run Code Online (Sandbox Code Playgroud)
唯一的问题是,我似乎无法让代码工作,我只需要代码为IE工作,我将使用媒体查询为其他(较新的)浏览器.关于我哪里出错的任何提示/提示?
到目前为止我有
<div id="floatdiv">
然后在那个div的末尾(哪里关闭)我有
<!--[if lt IE 9]>
<script type="text/javascript" src="http://dl.dropbox.com/u/17087195/website/sidebar_size.js"></script>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
在我的标题中我有
<script type='text/javascript' src='http://www.itsdaniel0.com/wp-includes/js/jquery/jquery.js?ver=1.4.4'></script>
我仍然无法使代码工作(在IE8中测试)我在某处仍然出错?
更新我确实有另一条jQuery链接,这可能导致问题吗?以下是完整的编码
<div id="floatdiv">
<div class="floating-menu">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.itsdaniel0.com%2F2011%2F03%2Funicorns-are-cool%2F&layout=box_count&show_faces=true&width=55&action=like&colorscheme=light&height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:55px; height:65px;" allowTransparency="true"></iframe>
<br /><br /><a href="http://twitter.com/share?url=http%3A%2F%2Fid0.me%2Fj0&counturl=http://www.itsdaniel0.com/2011/03/unicorns-are-cool/" class="twitter-share-button" data-text="Unicorns Are Cool" data-count="vertical" data-via="itsdaniel0 #itsdaniel0">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<br /><br />
<script src="http://widgets.fbshare.me/files/fbshare.js"></script>
</div>
</div>
<script type="text/javascript" src="http://dl.dropbox.com/u/17087195/website/sidebar.js"></script>
<!--[if lt IE …Run Code Online (Sandbox Code Playgroud)