滚动条在Chrome扩展程序中不可见

时间:2012-12-16 09:22:11

标签: google-chrome-extension scrollbar

我开发了一个chrome扩展名,如果弹出窗口中的内容超过弹出窗口的指定高度,则应该有一个滚动条。

我正在添加popup.html的内容

<!DOCTYPE html>
  <head>
    <title>Compare Hatke</title>
    <script type='text/javascript' src='popup.js'>
    </script>
    <style>
      body {
        min-width:357px;
        min-height: 500px;
        overflow-x:hidden;
        overflow-y:auto;
      }

      img {
        margin:5px;
        border:2px solid black;
        vertical-align:middle;
        width:75px;
        height:75px;
      }
    </style>
  </head>
  <body>

    Extension developed by Prashant Singh
  </body>
</html>

也是将数据注入弹出文件的JS

var len = currentArray.length;
  var string = "";

  for(i=0;i<len;i++){
    if(tab.id==currentArray[i].tabID){
     string += "<img src='" + currentArray[i].image + "' height='20px' max-width='100px'> " + currentArray[i].prod +"<br>";
    }
  }
  document.write(string);

可能出现什么问题?即使要显示的数据远远大于可以在一个视图中显示的数据,我也没有滚动条。

任何解释都将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:1)

在popup.html页面中添加了一个div

<body>
    <div id='showData'>
    Extension developed by Prashant Singh
  </div>
  </body>

并将document.write替换为document.getElementById('showData').innerHTML,它一闪而过。任何解释。为什么上一个没有用?

相关问题