如何使用 Greasemonkey 更改文本对齐方式?
我想改变这个CSS文本对齐。这是对的,但我希望它被留下。
<div class="btn_gonder" id="ContentPlaceHolder1_btnform">
<input border="0" type="image" style="height:36px;width:97px;" src="../style/images/btn_gonder.png" alt="Gönder" id="ContentPlaceHolder1_ImageButton1" name="ctl00$ContentPlaceHolder1$ImageButton1"></div>
CSS AREA
.select_container .btn_gonder {
float: left;
height: 36px;
text-align: right;
width: 304px;
}
HTML AREA
<div class="btn_gonder" id="ContentPlaceHolder1_btnform">
<input border="0" type="image" style="height:36px;width:97px;" src="../style/images/btn_gonder.png" alt="Gönder" id="ContentPlaceHolder1_ImageButton1" name="ctl00$ContentPlaceHolder1$ImageButton1"></div>
我的代码
我编写了这段代码,但它不起作用...... 如何使用 Greasemonkey 更改文本对齐方式?
<script>
window.onload=allign;
function allign(){
document.getElementById('ContentPlaceHolder1_btnform').style.text-align='left';
}
</script>
I want to change this CSS text-align. it's right but I want it to be left.
<div class="btn_gonder" id="ContentPlaceHolder1_btnform">
<input border="0" type="image" style="height:36px;width:97px;" src="../style/images/btn_gonder.png" alt="Gönder" id="ContentPlaceHolder1_ImageButton1" name="ctl00$ContentPlaceHolder1$ImageButton1"></div>
CSS AREA
.select_container .btn_gonder {
float: left;
height: 36px;
text-align: right;
width: 304px;
}
HTML AREA
<div class="btn_gonder" id="ContentPlaceHolder1_btnform">
<input border="0" type="image" style="height:36px;width:97px;" src="../style/images/btn_gonder.png" alt="Gönder" id="ContentPlaceHolder1_ImageButton1" name="ctl00$ContentPlaceHolder1$ImageButton1"></div>
MY CODE
I wrote this code but it's not work...
How Can i change text-align with Greasemonkey ?
<script>
window.onload=allign;
function allign(){
document.getElementById('ContentPlaceHolder1_btnform').style.text-align='left';
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有几点:
标签(或任何 HTML 标签)不能像在 Greasemonkey 脚本中那样使用。无论如何,在这种情况下不需要
的变体。
事件处理程序不能在 GM 脚本中这样设置.
在支持 GM 的浏览器中以这种方式设置样式时,您需要驼峰式标识符 IE
textAlign
。您可能不需要 onload,但我假设在这种情况下,表单不是静态加载(或样式化)的,而是通过 javascript 加载(或样式化)的。
把它们放在一起,你的代码将变成:
Several things:
<script>
tags (or any HTML tags) cannot be used like that in a Greasemonkey script. No variant of<script>
is need in this case, anyway.Event handlers cannot be set that way in GM scripts.
When setting styles that way, in GM-capable browsers, you need the camel-case identifier, IE
textAlign
.You probably do not need the onload, but I will presume that in this case the form is not statically loaded (or styled), but loaded (or styled) by javascript.
Putting it all together, your code would become:
您可以这样做:
This is how you can do it: