2012-12-03 75 views
-5

我制作了一个带有窗户PVC和PVC PVC产品的网站。 我想用计算器订购页面。它的工作,但我现在需要动画窗口的配置(比如:http://orasvirtual.ro/images/a.JPG)。 所以,默认的窗口大小为250像素,高度350像素和宽度。我做了4个按钮: (例如:http://orasvirtual.ro/images/b.JPG) 增加高度,降低高度,增加宽度和减小宽度。 我已经做到现在,但如何使增加/减少持有点击X秒。在单击按钮上单击按钮1秒删除/解码div尺寸

感谢所有

好了,到现在为止我做了这个,这要归功于空指针:

HTML:

<div id='divid'>div</div> 
<button id="inch" >+ h</button> 
<button id="dech" >- h</button> 
<button id="incw" >+ w</button> 
<button id="decw" >- w</button> 

的jQuery:

$("#inch").click(function(){ 

var height = $("#divid").height()+1; //to decrease just -1 instead of 1 

$("#divid").height(height); 
}) 
$("#dech").click(function(){ 

var height = $("#divid").height()-1; //to decrease just -1 instead of 1 

$("#divid").height(height); 
}) 
$("#incw").click(function(){ 

var width= $("#divid").width()+1; //to decrease just -1 instead of 1 

$("#divid").width(width); 
}) 
$("#decw").click(function(){ 

var width= $("#divid").width()-1; //to decrease just -1 instead of 1 

$("#divid").width(width); 
}) 
+0

发布您的代码。 – arulmr

+0

http://jsfiddle.net/9b52T/4/ – user1871756

回答

0

如果窗口元素是$(window)使用以下代码

增加宽度:

$(window).width($(window).width() + 1 + "px") 

减少宽度:

$(window).width($(window).width() - 1 + "px") 

增加身高:

$(window).height($(window).height() + 1 + "px") 

减少高度:

$(window).height($(window).height() - 1 + "px") 

钍anks

1

您无法更改window对象的宽度/高度,但可以更改body元素的宽度和高度。

$('#increaseWidth').click(function(){ 
    $('body').width(function(i, w){ 
     return w + 1 
    }) 
}) 

$('#decreaseHeight').click(function(){ 
    $('body').height(function(i, h){ 
     return h - 1 
    }) 
}) 

http://jsfiddle.net/HsHj8/

0

你不能这样做,在大多数的情况下。

来源:

由于火狐7,它不再可能一个网站,以改变浏览器窗口的默认大小,按以下规则:

  1. 你无法调整window.open未创建的窗口或选项卡的大小。
  2. 当它与多个选项卡的窗口不能调整窗口或标签。

对于一些支持的浏览器可以使用以下调整您的浏览器窗口。

window.resizeTo(w,h);