1

我正在寻找一个修复/解决方案,并找到了这个主题: http ://highslide.com/forum/viewtopic.php?t=3030

 function fixElement(el) {
    var stl = el.style;
    stl.position = 'fixed';
    stl.top = (parseInt(stl.top) - hs.page.scrollTop) +'px';
    stl.left = (parseInt(stl.left) - hs.page.scrollLeft) +'px';
}
function unfixElement(el) {
   var stl = el.style;
   stl.position = 'absolute';
   stl.top = (parseInt(stl.top) + hs.page.scrollTop) +'px';
   stl.left = (parseInt(stl.left) + hs.page.scrollLeft) +'px';
}

if (!hs.ie || hs.ieVersion() > 6) {
    hs.Expander.prototype.onAfterExpand = function() {
       fixElement (this.wrapper);
      if (this.outline) fixElement(this.outline.table);
   };

    hs.Expander.prototype.onBeforeClose = function() {
       unfixElement (this.wrapper);
      if (this.outline) unfixElement(this.outline.table);
   };
}

在论坛主题上获得了一个小技巧,但该技巧不适用于我尝试过的任何 Internet Explorer(IE7、IE8 和 IE9)。

有没有人对黑客有“修复”以使其在 IE 上运行?

我认为这与这部分代码有关,这种情况:

if (!hs.ie || hs.ieVersion() > 6)

我删除并且它有效,但也许可以更改此代码。

谢谢你。

4

1 回答 1

2

下面的代码就是你需要的。现场演示:http ://www.highslide.com/studies/position-fixed.html
注意:需要 highslide-full.js

    // Highslide fixed popup mod. Requires the "Events" component.
    if (!hs.ie || hs.uaVersion > 6) hs.extend ( hs.Expander.prototype, {
      fix: function(on) {
        var sign = on ? -1 : 1,
          stl = this.wrapper.style;

        if (!on) hs.getPageSize(); // recalculate scroll positions


        hs.setStyles (this.wrapper, {
          position: on ? 'fixed' : 'absolute',
          zoom: 1, // IE7 hasLayout bug,
          left: (parseInt(stl.left) + sign * hs.page.scrollLeft) +'px',
          top: (parseInt(stl.top) + sign * hs.page.scrollTop) +'px'
        });

        if (this.outline) {
          stl = this.outline.table.style;
          hs.setStyles (this.outline.table, {
            position: on ? 'fixed' : 'absolute',
            zoom: 1, // IE7 hasLayout bug,
            left: (parseInt(stl.left) + sign * hs.page.scrollLeft) +'px',
            top: (parseInt(stl.top) + sign * hs.page.scrollTop) +'px'
          });

        }
        this.fixed = on; // flag for use on dragging
      },
      onAfterExpand: function() {
          this.fix(true); // fix the popup to viewport coordinates
      },

      onBeforeClose: function() {
        this.fix(false); // unfix to get the animation right
      },

        onDrop: function() {
          this.fix(true); // fix it again after dragging
      },

      onDrag: function(sender, args) {
        //if (this.fixed) { // only unfix it on the first drag event
          this.fix(true);
        //}
      }

    });
于 2013-07-09T00:26:11.990 回答