当我放大Web浏览器时,JS脚本不起作用

时间:2013-12-01 04:46:50

标签: javascript browser jwplayer

有人可以解释为什么当我放大我的网页浏览器时这个js脚本不起作用吗?

function resizePlayer(){
 if(jwplayer().getWidth() == 596) { 
 jwplayer().resize(1004,565); 

 } else {
 jwplayer().resize(596,335);

 }
 };

1 个答案:

答案 0 :(得分:1)

function resizePlayer(){
 if(jwplayer().getWidth() == 596) { 
 jwplayer().resize(1004,565); 

 } else {
 jwplayer().resize(596,335);

 }
 };


you need attach the listener to an element such as window :

window.onresize = resizePlayer;

http://www.w3schools.com/jsref/event_onresize.asp