Jquery 将视图端口高度添加到Javascript插件

Jquery 将视图端口高度添加到Javascript插件,jquery,height,viewport,Jquery,Height,Viewport,我有一个javascript横幅,它有一个默认的宽度和高度,我想在其中添加视图端口高度。(我不能把100%或自动,因为插件不工作,我应该添加像100px等值)。下面是javascript <script type="text/javascript"> $(document).ready(function(){ var h=$(window).height(); $('#slideshow').fadeSlideShow({ PlayPause

我有一个javascript横幅,它有一个默认的宽度和高度,我想在其中添加视图端口高度。(我不能把100%或自动,因为插件不工作,我应该添加像100px等值)。下面是javascript

        <script type="text/javascript">
$(document).ready(function(){
   var h=$(window).height();
  $('#slideshow').fadeSlideShow({
        PlayPauseElement: false,
        NextElement: false,
        PrevElement: false,
        ListElement: false,
        width: '100%',
        height: h+'px'
    });

    });
</script>

$(文档).ready(函数(){
var h=$(window.height();
$(“#幻灯片放映”).fadeSlideShow({
playbauseelement:false,
NextElement:false,
元素:false,
李斯特:错,
宽度:“100%”,
高度:h+‘px’
});
});
请给我提个建议

非常感谢

var h=$(window).height()
在css(传递给插件对象的设置)中,您必须编写

$('#slideshow').fadeSlideShow({
    PlayPauseElement: false,
    NextElement: false,
    PrevElement: false,
    ListElement: false,
    width: '100%',
    height: h+'px';
});
编辑下面是使用SimpleFadeSlideShow插件进行全屏幻灯片放映的示例代码。但我仍然建议根据所需的幻灯片大小使用足够大的图像,以防止图像的像素化

<html>
<head>
<script src="jq.js" type="text/javascript"></script>
<script src="slideshow/fadeslideshow.js" type="text/javascript"></script>
<link href="slideshow/demostylesheet.css" rel="stylesheet" type="text/css">
<script>

$(document).ready(function(){

var h=$(window).height();
var w=$(window).width();


$('#slideshow').css({
margin: '0px',
padding: '0px'
})

$('body').css('overflow','hidden')

$.when($('#slideshow').find('img').css
({
width: w+'px',
height: h+'px'
})

).then($('#slideshow').fadeSlideShow({
    PlayPauseElement: false,
    NextElement: false,
    PrevElement: false,
    ListElement: false,
    width: w+'px',
    height: h+'px'
})
)



$(window).on('resize',function(){

$(document).ready(function(){

$('body').css('overflow','visible')

$(window).scrollTop($(window).height())

$('#slideshow').find('*').css({

 width: $(window).width()+'px',
 height: $(window).height()+'px'
})

$('#slideshow').find('*').css({
   width: $(window).width()+20+'px',
   height: $(window).height()-$(window).scrollTop()+17+'px'
})

$(window).scrollTop(0);

$('body').css('overflow','hidden')

$('#slideshow').css({height : $(window).height()+'px', width: $(window).width()+'px'})


})
});
 });

</script>

</head>
<body>
<ul id="slideshow" style="width: 640px; height: 480px; position: relative; overflow: hidden;">

<!-- This is the last image in the slideshow--> 
<li style="position: absolute; width: 640px; height: 480px; display: list-item;">
    <img src="http://www.simplefadeslideshow.com/wp-content/themes/simplefadeslideshow_com/images/3.jpg" width="640" height="480" border="0" alt="">
</li>
<li style="position: absolute; width: 640px; height: 480px; display: list-item;">
    <img src="http://www.simplefadeslideshow.com/wp-content/themes/simplefadeslideshow_com/images/2.jpg" width="640" height="480" border="0" alt="">
</li>
<li style="position: absolute; width: 640px; height: 480px; display: list-item; opacity: 0.7128896457825363;">
    <img src="http://www.simplefadeslideshow.com/wp-content/themes/simplefadeslideshow_com/images/1.jpg" width="640" height="480" border="0" alt="">
</li>
<!-- This is the first image in the slideshow -->
</ul>
</body>
</html>

$(文档).ready(函数(){
var h=$(window.height();
var w=$(window.width();
$(“#幻灯片放映”).css({
边距:“0px”,
填充:“0px”
})
$('body').css('overflow','hidden'))
$.when($('#slideshow').find('img').css
({
宽度:w+‘px’,
高度:h+‘px’
})
)。然后($(“#幻灯片放映”)。fadeSlideShow({
playbauseelement:false,
NextElement:false,
元素:false,
李斯特:错,
宽度:w+‘px’,
高度:h+‘px’
})
)
$(窗口).on('resize',function()){
$(文档).ready(函数(){
$('body').css('overflow','visible'))
$(窗口).scrollTop($(窗口).height())
$(“#幻灯片放映”).find(“*”).css({
宽度:$(窗口).width(),
高度:$(窗口).height()+'px'
})
$(“#幻灯片放映”).find(“*”).css({
宽度:$(窗口).width()+20+'px',
高度:$(窗口).height()-$(窗口).scrollTop()+17+'px'
})
$(窗口).scrollTop(0);
$('body').css('overflow','hidden'))
$('#slideshow').css({height:$(window.height()+'px',width:$(window.width()+'px'))
})
});
});

我试图将值添加到css中,但它只从javascript$(“#slideshow”)中获取高度。fadeSlideShow({PlayPauseElement:false,NextElement:false,PrevElement:false,ListElement:false,width:'100%,height:h,//这里我需要添加})@Gops我不明白你说的从javascript中获取高度是什么意思?我试图添加一个样式表,如#slideshow li img{height:900 px;width:100%},但是当脚本呈现时,它只给出javascript中给定的高度。我已经用你给出的内容更新了我的脚本。。但它仍然没有达到高度。。请查看script@Gops我已经通过创建一个网页测试了插件。给插件提供视口高度或宽度只会改变幻灯片框的尺寸,而不会改变图像,因此,如果图像很小,不管你提供的宽度或高度有多大,你都不会得到全屏幻灯片。因此,您可以根据您的要求使用较大的图像,或者等待一段时间,我会看看下次是否可以做一些事情。请不要根据给出的答案修改您的问题(如果问题中没有输入错误或您在发布时犯了错误)因为这会使其他人对问题产生混淆,他们可以解释为回答者在回答中重新发布了问题代码,这将导致对答案的否决投票。@UDB请原谅我的错误。。