代码实例
function sleepcheckvideo(){
// alert('here is a function');
setTimeout(function() {
if(screen.width<768 ){
// alert("这是手机");
if(document.body.clientWidth>window.screen.width){
// alert("屏幕是横着放的");
if($(".lesson-content-text-body")){
alert('为了更好的用户体验,请将手机垂直放置浏览课程');
}
}else{
if($(".lesson-content-text-body")){
if($(".lesson-content-text-body iframe").attr("width")){
$(".lesson-content-text-body iframe").attr("width", 240);
$(".lesson-content-text-body iframe").attr("height",160);
}else{
sleepcheckvideo();
}
}
}
}else{
if($(".lesson-content-text-body")){
if($(".lesson-content-text-body iframe").attr("width")){
$(".lesson-content-text-body iframe").attr("width", 700);
$(".lesson-content-text-body iframe").attr("height",400);
}else{
sleepcheckvideo();
}
}
}
},500);
}
本文介绍了一个用于检查用户屏幕尺寸并根据不同设备类型调整课程内容显示大小的JavaScript函数。该函数能够识别手机和平板设备,并根据设备方向改变嵌入式视频的尺寸,以提升用户体验。

5503

被折叠的 条评论
为什么被折叠?



