最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

支持iframe自适应,并全屏iframe_html/css

来源:动视网 责编:小采 时间:2020-11-27 16:36:15
文档

支持iframe自适应,并全屏iframe_html/css

支持iframe自适应,并全屏iframe_html/css_WEB-ITnose:support iframe responsive and fullscreen iframe(支持iframe自适应,并全屏iframe) ################################################################### 1.use jquery iframe resizer(it wi
推荐度:
导读支持iframe自适应,并全屏iframe_html/css_WEB-ITnose:support iframe responsive and fullscreen iframe(支持iframe自适应,并全屏iframe) ################################################################### 1.use jquery iframe resizer(it wi


support iframe responsive and fullscreen iframe(支持iframe自适应,并全屏iframe)

###################################################################

1.use jquery iframe resizer(it will autoresize iframe when content change)

and more fullscreen a iframe

2.user jquery fullscreen plugin

here ,the problem is iframe resizer set the iframe's scrolling="no",so in fullscreen,when content is more than 1 screen, there is no scroll bar.

so before you call $(iframe).fullscreen(),set iframe.scrolling="auto".


3.when exit fullscreen ,we need to set scrolling="no" ,otherwise it will continue response but ugly because of the scroll bar.

so ,we detect the fullscreen state,where exit fullscreen ,we set iframe's scrolling attribute to "no".

I write the content in iframe's container page as followes:




/*

* detect fullsreen state,when is no full screen , just set the iframe.scrolling="no";

*/

function onFullscreenchange(e) {

// Mode has changed.

console.log("onFullscreenchange");

/**

* Prior to Internet Explorer 11 not implemented

IE11 msFullscreenElement

Microsoft Edge and beyond fullscreenElement

*/

if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement||document.fullscreenElement)

{

/* Run code on exit */

}else{//exit fulscreen, set current iframe scrolling = no

if(lastFullScreenIframe!=null && lastFullScreenIframe!=undefined)

{

lastFullScreenIframe[0].scrolling="no";//no in fullscreen mode ,set scrolling no

}

}

}

jQuery(document).ready(function() {

document.addEventListener("fullscreenchange", onFullscreenchange, false);

document.addEventListener("webkitfullscreenchange", onFullscreenchange, false);

document.addEventListener("mozfullscreenchange", onFullscreenchange, false);

document.addEventListener("MSFullscreenChange", onFullscreenchange, false);//ie 11

});



have fun ,any problem mail me xiaohelong2005@gmail.com

########################################################################

the follow is in chinese:

iframe resizer plugin: https://github.com/davidjbradshaw/iframe-resizer

jquery fullscreen plugin: https://github.com/kayahr/jquery-fullscreen-plugin

自已写的侦测全屏事件函数等.

过程说明:

1.按iframe resizer方式实现好。(需要注意的是,每新增一个iframe,需要调用一次初始化函数)

2.按jquery fullpage方式实现好iframe全屏(获取到该iframe对像,调用fullpage)


3.此时虽然已经能在非全屏模式正常工作,但是在全屏方式,内容较多时确并不会出现滚动条。

解决如下:

在$(iframe).fullpage()调用前,设定iframe.scrolling="auto",并用lastFullScreenIframe记下最近一个iframe(多tab情况下)

解决了全屏模式下的滚动条问题,但是在非全屏下我们又必须将scrolling="no"关闭。解决思路如下:

监测全屏事件,当退出全屏时设定iframe.scrolling="no".

在iframe的父亲框架中,加入以下功能:


/*

* detect fullsreen state,when is no full screen , just set the iframe.scrolling="no";

*/

function onFullscreenchange(e) {

// Mode has changed.

console.log("onFullscreenchange");

/**

* Prior to Internet Explorer 11 not implemented

IE11 msFullscreenElement

Microsoft Edge and beyond fullscreenElement

*/

if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement||document.fullscreenElement)

{

/* Run code on exit */

}else{//exit fulscreen, set current iframe scrolling = no

if(lastFullScreenIframe!=null && lastFullScreenIframe!=undefined)

{

lastFullScreenIframe[0].scrolling="no";//no in fullscreen mode ,set scrolling no

}

}

}

jQuery(document).ready(function() {

document.addEventListener("fullscreenchange", onFullscreenchange, false);

document.addEventListener("webkitfullscreenchange", onFullscreenchange, false);

document.addEventListener("mozfullscreenchange", onFullscreenchange, false);

document.addEventListener("MSFullscreenChange", onFullscreenchange, false);//ie 11

});

文档

支持iframe自适应,并全屏iframe_html/css

支持iframe自适应,并全屏iframe_html/css_WEB-ITnose:support iframe responsive and fullscreen iframe(支持iframe自适应,并全屏iframe) ################################################################### 1.use jquery iframe resizer(it wi
推荐度:
标签: 全屏 it html
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top