Javascript 将某物附加到变量上
我有密码Javascript 将某物附加到变量上,javascript,screen,append,resolution,Javascript,Screen,Append,Resolution,我有密码 <script type="text/javascript"> var yourImg = document.getElementById('image'); if(yourImg && yourImg.style) { yourImg.style.height = screen.availWidth; yourImg.style.width = screen.availHeight; } </script>
<script type="text/javascript">
var yourImg = document.getElementById('image');
if(yourImg && yourImg.style) {
yourImg.style.height = screen.availWidth;
yourImg.style.width = screen.availHeight;
}
</script>
var yourImg=document.getElementById('image');
if(yourImg&&yourImg.style){
yourImg.style.height=screen.availWidth;
yourImg.style.width=screen.availHeight;
}
我需要在宽度和高度的末尾加上px
提前感谢,,
Chase您没有提供太多信息,但是:
screen.availWidth + 'px';
screen.availHeight + 'px';
javascript中字符串(和其他值)的串联使用“+”(加号)字符。在代码中:
<script type="text/javascript">
var yourImg = document.getElementById('image');
if(yourImg && yourImg.style) {
yourImg.style.height = screen.availWidth;
yourImg.style.width = screen.availHeight;
var height = yourImg.style.height + 'px';
var width = yourImg.style.width + 'px';
}
</script>
var yourImg=document.getElementById('image');
if(yourImg&&yourImg.style){
yourImg.style.height=screen.availWidth;
yourImg.style.width=screen.availHeight;
var height=yourImg.style.height+'px';
var width=yourImg.style.width+'px';
}
yourImg.style.height=screen.availWidth+'px'
yourImg.style.width=screen.availHeight+'px' -1因为这是最基本的语言,即使是最基本的Javascript入门也会教你。