admin管理员组文章数量:1325761
I would like to resize the pagewrapper div with javascript. I have chrome and would like to use it as userscript. Here is the site link: . I want to take the pagewrapper to 100% width. I have the following code:
// ==UserScript==
// @match /*
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", ".4.2/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function pagewrapper() {
document.getElementById('pagewrapper').style.Width = "100%";
}
addJQuery(pagewrapper);
I would like to resize the pagewrapper div with javascript. I have chrome and would like to use it as userscript. Here is the site link: http://clanbase.ggl.. I want to take the pagewrapper to 100% width. I have the following code:
// ==UserScript==
// @match http://clanbase.ggl./*
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis./ajax/libs/jquery/1.4.2/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function pagewrapper() {
document.getElementById('pagewrapper').style.Width = "100%";
}
addJQuery(pagewrapper);
Share
Improve this question
edited Oct 7, 2012 at 12:45
Hovercraft Full Of Eels
285k25 gold badges266 silver badges388 bronze badges
asked Oct 7, 2012 at 12:43
Zsolt JanesZsolt Janes
8402 gold badges9 silver badges26 bronze badges
4
- 1 Consider changing tags here from java to javascript. They are quite different programming languages. Edit: never mind, I'll do it for you! – Hovercraft Full Of Eels Commented Oct 7, 2012 at 12:44
-
I believe,
width
needs to start with lowercasew
. In addition, if you're already loading jQuery, why not just do$('#pagewrapper').css('width','100%');
? – Aleks G Commented Oct 7, 2012 at 12:49 - Also, you'll want to wrap that in the in the domready or load event, so $(document).ready(pagewrapper); – hobberwickey Commented Oct 7, 2012 at 12:52
- 1 Sorry but I'm not javascript coder I found some scripts. – Zsolt Janes Commented Oct 7, 2012 at 13:12
1 Answer
Reset to default 5One thing to note is that non-absolutely positioned divider elements automatically take up 100% of the width, so you might not need to do anything. Just try removing the width property from the pagewrapper
element (in the CSS) and see if it works. You could also try overriding the width property:
#pagewrapper {
width:100%;
}
If setting CSS isn't an option for whatever reason, this script should suffice:
function pagewrapper() {
document.getElementById('pagewrapper').style.width = "100%";
}
本文标签: How to resize div width with javascriptStack Overflow
版权声明:本文标题:How to resize div width with javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742191397a2430280.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论