iframe自动高度 12306
来源:互联网 发布:python sin函数图像 编辑:程序博客网 时间:2024/04/20 00:57
//12306 iframe自动高度
function doIframe() {
o = document.getElementsByTagName('iframe');
for ( var i = 0; i < o.length; i++) {
if (/\bautoHeight\b/.test(o[i].className)) {
setHeight(o[i]);
addEvent(o[i], 'load', doIframe);
}
}
}
function setHeight(e) {
// 目前测试的ie8、firefox3.6.3、google、搜狗浏览器都可以使用
try {
var height = e.contentWindow.document.body.scrollHeight;
if (height < 300) {
height = 300;
}
e.height = height + 30;
var ictheight = height + 80;
if(userAgent() != "ie9"){
document.getElementById('ictiframe').src = "http://www.12306.cn/mormhweb/ggxxfw/wbyyzj/201105/t20110529_1905.jsp?height="
+ ictheight;
}
} catch (ex) {
e.height = 710;
if(userAgent() != "ie9"){
document.getElementById('ictiframe').src = "http://www.12306.cn/mormhweb/ggxxfw/wbyyzj/201105/t20110529_1905.jsp?height=" + 780;
}
}
}
function addEvent(obj, evType, fn) {
if (obj.addEventListener) {
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent) {
obj.detachEvent("on" + evType, fn);
var r = obj.attachEvent("on" + evType, fn);
return r;
} else {
return false;
}
}
function userAgent() {
var ua = navigator.userAgent;
ua = ua.toLowerCase();
var match = /(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
!/compatible/.test(ua) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec(ua) || [];
// 如果需要获取浏览器版本号:match[2]
if(match[1] == "msie"){
if (parseInt(match[2]) === 7) // ie7
{
if(ua.indexOf("trident/5.0") != -1){// ie9 此处为当ie9处于兼容模式下时的情况
return "ie9";
}else{
return match[1];
}
}else if (parseInt(match[2]) === 9) // ie9
{
return "ie9";
}else{
return match[1];
}
}else{
return match[1];
}
}
if (document.getElementById && document.createTextNode) {
addEvent(window, 'load', doIframe);
}
- iframe自动高度 12306
- iframe自动调整高度
- iframe自动调整高度
- iframe自动自适应高度
- 自动伸缩iframe高度
- 自动伸缩iframe高度
- iframe高度自动适应
- iframe自动适应高度
- iframe自动高度
- iframe 高度自动适应
- Iframe自动适应高度
- iframe高度自动适应
- IFRAME 自动适应高度
- Iframe自动适应高度
- iframe自动适应高度
- iframe自动适应高度
- iframe 自动适应高度
- iframe高度自动调整
- Linux内核的Container_of机制
- webkit中的javascript(4)---javascript执行的入口
- android.graphics.Bitmap.Config<ALPHA_8, ARGB_4444,ARGB_8888,RGB_565>
- 基于Spring JdbcTemplate 的分页处理
- django中自定义orm,修改默认规则
- iframe自动高度 12306
- 在 NetBeans IDE 中调试 PHP 源代码
- django的通用视图 (generic views)
- 破解工具
- 关于c语言中交换两个数的方法
- According to TLD, tag s:property must be empty, but is not
- 额外分为二个人题外话
- ViewPager实现引导界面以及进入下一个activity解决办法
- 客户端套接字(Socket)的超时