为什么这些日历javascripts隐藏选择,applet和iframe标签为IE? [英] why do these calendar javascripts hide select, applet, and iframe tags for IE?

查看:134
本文介绍了为什么这些日历javascripts隐藏选择,applet和iframe标签为IE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图诊断一个较旧网站的问题,而不是我支持的问题。问题是在IE8中,一个SELECT标签被隐藏。原来是由于一个旧版本的calendar.js应用 visibility:hidden 风格不仅选择标签,而且applet和iframe。

I'm trying to diagnose a problem with an older site than I'm supporting. The problem is that in IE8, a SELECT tag is being hidden. Turns out it is due to an older version of a calendar.js which is applying visibility:hidden style to not only SELECT Tags, but also applets and iframes.

我对我的javascript和旧的浏览器怪癖的细节生锈,但我发现奇怪的是,它是隐藏这些标签,当他们与日历无关。在有问题的页面中,隐藏的此选择标记位于日历对象上方的div中,但它们的形式相同。

I'm rusty on my javascript and details of older browser quirks, but the thing I find odd is that it's hiding these tags when they are unrelated to the calendar. In the page with the problem, this select tag that's being hidden is in a div above the calendar objects, although they are in the same form.

这是一个问题IE的早期版本?如果要检查IE的版本,并且不将这些样式应用于版本8和更高版本,它是否安全?

Is this a problem with an earlier version of IE? Would it be 'safe' to put in an if to check the version of IE, and not apply these styles for version 8 and later?

这是日历的功能。 js:

Here's the function from calendar.js:

Calendar.prototype.hideShowCovered = function () {
  if (!Calendar.is_ie && !Calendar.is_opera)
    return;
  function getVisib(obj){
    var value = obj.style.visibility;
    if (!value) {
      if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
        if (!Calendar.is_khtml)
          value = document.defaultView.
            getComputedStyle(obj, "").getPropertyValue("visibility");
        else
          value = '';
      } else if (obj.currentStyle) { // IE
        value = obj.currentStyle.visibility;
      } else
        value = '';
    }
    return value;
  };

  var tags = new Array("applet", "iframe", "select");
  var el = this.element;

  var p = Calendar.getAbsolutePos(el);
  var EX1 = p.x;
  var EX2 = el.offsetWidth + EX1;
  var EY1 = p.y;
  var EY2 = el.offsetHeight + EY1;

  for (var k = tags.length; k > 0; ) {
    var ar = document.getElementsByTagName(tags[--k]);
    var cc = null;

    for (var i = ar.length; i > 0;) {
      cc = ar[--i];

      p = Calendar.getAbsolutePos(cc);
      var CX1 = p.x;
      var CX2 = cc.offsetWidth + CX1;
      var CY1 = p.y;
      var CY2 = cc.offsetHeight + CY1;

      if (this.hidden || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
        if (!cc.__msh_save_visibility) {
          cc.__msh_save_visibility = getVisib(cc);
        }
        cc.style.visibility = cc.__msh_save_visibility;
      } else {
        if (!cc.__msh_save_visibility) {
          cc.__msh_save_visibility = getVisib(cc);
        }
        cc.style.visibility = "hidden";
      }
    }
  }
};


推荐答案

这些对象总是在

不再是真的

It's no longer true for select in any modern browser, and (you'd need to test it but) I suspect the same thing is true for iframe. They certainly don't have this problem in IE8.

applet ,另一方面,这个问题,是一个嵌入页面的重量级窗口。在重量级窗口模式下的Flash也会有同样的问题。

applet, on the other hand, almost certainly still has the problem, being a heavyweight window embedded into the page. Flash in heavyweight-window mode will have the same problem too.

这篇关于为什么这些日历javascripts隐藏选择,applet和iframe标签为IE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆