简体   繁体   中英

push menu doesn't work only in IE9

why my slide menu doesn't work only on IE9:
HERE IS MY LINK : http://500milligrammes.com/fmzz/final/news/zzz/index.html#

HERE IS AUTHOR'S LINK : http://callmenick.com/_development/slide-push-menus/



HERE IS MY HTML CODE :

<link property="stylesheet" rel="stylesheet" type="text/css" href="../../css/font/font.css"/>
<link property="stylesheet" rel="stylesheet" type="text/css" href="../../css/style.css"/>
<style type="text/css">
body  { background:#fff; position:absolute; width:100%; height:100%; scrollbar-arrow-color: #e1e1e1; scrollbar-track-color: #fff;}
@media (max-width:1200px) { body   { overflow-y:scroll; overflow-x:hidden; scrollbar-arrow-color: #fff; scrollbar-track-color: #f1f1f0;} }
</style>
</head>

<body id="top">

<div style="height: 100%;" id="container">
<div style="height: 100%; width:100%; position:absolute;" id="o-wrapper" class="o-wrapper">

<div class="header">

<div class="leftcolumn">
<div style="margin-left: 0px;" id="c-button--push-left" class="c-button">
MENU
</div> 
</div>

<div class="rightcolumn"><a class="linkright" href="#top">TOP</a></div>

<div class="logocolumn"></div>

</div>

<div id='main'>

<div id='left'>
<div style="margin-left:30px; margin-bottom:20px;">
<a href="#">Link 1</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="#">Link 2</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="#">Link 3</a>
</div>

<div style="margin: 0px 30px 20px 30px;">
<span style="100%" class="newstitle">TITLE</span>
<p style="margin-top:-7px;" >Blablabla</p>
<hr class="gridnews">

<div class="flipper">1</div>
<div style="margin:10px 0px 0px 0px; display:block;" class="flip">
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?" But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"  ...
<br/><br/><a href="#">Read more >></a>
</div>

<div style="margin-top:20px; " class="flipper">2</div>
<div style="margin-top:10px;" class="flip">
blabla
</div>

<div style="margin-top:20px; " class="flipper">3</div>
<div style="margin-top:10px;" class="flip">
blabla
</div>

<div style="margin-top:20px; clear: left;">&nbsp;&nbsp;&nbsp;</div>
</div>

<div style="height:18px;"></div>
</div>

<div id='right'>
<div class="lazy">
<img class="imgstylefirst" data-src="img/2.jpg" src="../../css/news/loading.gif" alt=""/><br/>
<div class="creditstyleempty"></div>
</div>

<div class="lazy">
<img class="imgstyle" data-src="img/3.jpg" src="../../css/news/loading.gif" alt=""/><br/>
<div class="creditstyleempty"></div>
</div>

<div class="lazy">
<img class="imgstyle" data-src="img/4.jpg" src="../../css/news/loading.gif" alt=""/>
<div class="creditstylelast"></div>
</div>

<div style="height:18px;"></div>

</div>

</div>

</div>

<nav style="border-right:0.1em solid #404040;" id="c-menu--push-left" class="c-menu c-menu--push-left"><ul class="c-menu__items">

<li class="c-menu__item"><a href="#" class="c-menu__link">FRANCE<br/></a></li>
<li class="c-menu__item"><a href="#" class="c-menu__link">AUSTRIA</a></li>
<li class="c-menu__item"><a href="#" class="c-menu__link">JAPAN</a></li>
<li class="c-menu__item"><a href="#" class="c-menu__link">GERMANY</a></li>
<li class="c-menu__close">CLOSE</li>

<li style="z-index:1; position:absolute; bottom:0px; margin-left:10px; width: 90%; text-align:left; top: auto;" class="c-menu__item">
<a class="footerlinks" href="#">one</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a class="footerlinks" href="#">two</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a class="footerlinks" href="#">three</a>
</span>
</li>
</ul></nav>

</div>

<div id="c-mask" class="c-mask"></div>

<script src="../../css/infinitescroll/jquery.unveil.js"></script>
<script type="text/javascript">
$(function() {
$(".lazy img").unveil(1000);
});
</script> 
<script type="text/javascript" src="../../css/scrolltotop/modernizr.js"></script>
<script type="text/javascript" src="../../css/scrolltotop/scrolltotop.js"></script>
<script type="text/javascript" src="../../css/scrolltotop/scripts.js"></script>
<script type="text/javascript" src="../../css/scrolltotop/waypoints.min.js"></script>
<script type="text/javascript" src="../../css/scrolltotop/hidebacktotop.js"></script>

<script type="text/javascript" src="../../css/menu/headerresize.js"></script>
<script type="text/javascript" src="../../css/menu/menu.js"></script>
<script type="text/javascript" src="../../css/menu/menupush.js"></script>
<script type="text/javascript" src="../../css/news/readmore.js"></script>
</body>
</html>

HERE IS MY CSS PART :

ul.c-menu__items { display: block; margin: 0 auto; position: relative; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; transform-style: preserve-3d; height: 100%; }

li.c-menu__item { position: relative; top: 40%; -webkit-transform: translateY(-40%); -ms-transform: translateY(-40%); transform: translateY(-40%); }

.c-button:hover { color:#e0ccb4; } 
a.c-menu__link:hover { color:#e0ccb4; }

.c-button,.c-menu__close { -moz-appearance:none; appearance:none; border-radius:none; -webkit-appearance:none; box-shadow:none; cursor:pointer; }

.c-button:focus,.c-menu__close:focus { outline:0 }

.c-mask, .c-menu { position:fixed; }

.o-wrapper { transition:transform .3s }

.c-menu,.o-wrapper { -webkit-transition:-webkit-transform .3s; }

.c-menu { z-index:200; background-color:#282828; transition:transform .3s;  }

.c-menu__items { list-style:none; margin:0; padding:0; }

.c-menu--push-left { width:100%;height:100%;overflow-y:hidden }

.c-menu--push-left .c-menu__item { display:block; text-align:center;}

.c-menu--push-left .c-menu__item:first-child { border-top:none }

.c-menu--push-left .c-menu__item:last-child:last-child { border-bottom:none }

.c-menu--push-left .c-menu__link { display:block; padding-left:20px; margin-bottom:20px; padding-top: 0px; color:#fff; text-align:left; }

.c-menu--push-left .c-menu__close { display:block; padding-left:20px; padding-top: 0px; width:100% }

.c-menu--push-left { top:0;left:0;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%) }

.c-menu--push-left.is-active { -webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0); }

.c-mask,body.has-active-menu { overflow:hidden }

.o-wrapper.has-push-left { -webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%) }

.c-mask { z-index:100;top:0;left:0;width:0;height:0;background-color:#282828;opacity:0;-webkit-transition:opacity .3s,width 0s .3s,height 0s     .3s;transition:opacity .3s,width 0s .3s,height 0s .3s }

.c-mask.is-active { width:100%;height:100%;opacity:.7;-webkit-transition:opacity .3s;transition:opacity .3s }

/* media queries */
@media all and (max-width:660px) { #carbonads { display:none } }

@media all and (min-width:450px) { 
.c-menu__close { color:#fff; font-size:0px;  height:0; margin:0; padding:0; position:fixed}
.c-menu--push-left { width:300px } 
.o-wrapper.has-push-left { -webkit-transform:translateX(300px); -ms-transform:translateX(300px); transform:translateX(300px) }
}

@media all and (max-width:450px) { 
.c-menu__items { font-size:8px;}

.c-menu__close { color:#fff;  font-size:8px; margin:0; padding:0; display:none; position: fixed; top:10px; cursor:pointer;}
.c-menu__close:hover { color:#e0ccb4; }
.c-menu--push-left { width:450px } 
.o-wrapper.has-push-left { -webkit-transform:translateX(450px); -ms-transform:translateX(450px); transform:translateX(450px) }
}

@media all and (max-height:480px) { 
.c-menu__items { font-size:8px;}
.c-menu__close { color:#fff;  font-size:8px; margin:0; padding:0; display:none; position: fixed; top:10px; cursor:pointer;}
.c-menu__close:hover { color:#e0ccb4; }

li.c-menu__item { font-size:8px; position: relative; top: 30%; -webkit-transform: translateY(-30%); -ms-transform: translateY(-30%); transform: translateY(-30%); } 
} 

@media all and (max-height:300px) { 
.c-menu__items { font-size:8px;}
.c-menu__close { color:#fff;  font-size:8px; margin:0; padding:0; display:none; position: fixed; top:10px; cursor:pointer;}
.c-menu__close:hover { color:#e0ccb4; }

li.c-menu__item { font-size:8px; position: relative; top: 25%; -webkit-transform: translateY(-25%); -ms-transform: translateY(-25%); transform: translateY(-25%); }  } 

HERE IS MY menupush.js CODE :

  var pushLeft = new Menu({
  wrapper: '#o-wrapper',
  type: 'push-left',
  menuOpenerClass: '.c-button',
  maskId: '#c-mask'
  });

  var pushLeftBtn = document.querySelector('#c-button--push-left');
  pushLeftBtn.addEventListener('click', function(e) {
  e.preventDefault;
  pushLeft.open();
  });

HERE IS MY menu.js CODE :

  (function(window) {
 'use strict';

 /**
 * Extend Object helper function.
 */
 function extend(a, b) {
 for(var key in b) { 
  if(b.hasOwnProperty(key)) {
    a[key] = b[key];
  }
 }
 return a;
 }

/**
* Each helper function.
*/
function each(collection, callback) {
for (var i = 0; i < collection.length; i++) {
  var item = collection[i];
  callback(item);
}
}

/**
* Menu Constructor.
*/
function Menu(options) {
this.options = extend({}, this.options);
extend(this.options, options);
this._init();
}

/**
* Menu Options.
*/
Menu.prototype.options = {
wrapper: '#o-wrapper',          // The content wrapper
type: 'slide-left',             // The menu type
menuOpenerClass: '.c-button',   // The menu opener class names (i.e. the buttons)
maskId: '#c-mask'               // The ID of the mask
};

/**
* Initialise Menu.
*/
Menu.prototype._init = function() {
this.body = document.body;
this.wrapper = document.querySelector(this.options.wrapper);
this.mask = document.querySelector(this.options.maskId);
this.menu = document.querySelector('#c-menu--' + this.options.type);
this.closeBtn = this.menu.querySelector('.c-menu__close');
this.menuOpeners = document.querySelectorAll(this.options.menuOpenerClass);
this._initEvents();
};

/**
* Initialise Menu Events.
*/
Menu.prototype._initEvents = function() {
// Event for clicks on the close button inside the menu.
this.closeBtn.addEventListener('click', function(e) {
  e.preventDefault();
  this.close();
}.bind(this));

// Event for clicks on the mask.
this.mask.addEventListener('click', function(e) {
  e.preventDefault();
  this.close();
}.bind(this));
};

/**
* Open Menu.
*/
Menu.prototype.open = function() {
this.body.classList.add('has-active-menu');
this.wrapper.classList.add('has-' + this.options.type);
this.menu.classList.add('is-active');
this.mask.classList.add('is-active');
this.disableMenuOpeners();
};

/**
 * Close Menu.
*/
Menu.prototype.close = function() {
this.body.classList.remove('has-active-menu');
this.wrapper.classList.remove('has-' + this.options.type);
this.menu.classList.remove('is-active');
this.mask.classList.remove('is-active');
this.enableMenuOpeners();
};

/**
* Disable Menu Openers.
*/
Menu.prototype.disableMenuOpeners = function() {
each(this.menuOpeners, function(item) {
  item.disabled = true;
});
};

/**
* Enable Menu Openers.
*/
Menu.prototype.enableMenuOpeners = function() {
each(this.menuOpeners, function(item) {
  item.disabled = false;
});
};

/**
* Add to global namespace.
*/
window.Menu = Menu;

})(window);

I don't know if this is the only issue, but .classList is not supported in IE until IE10.

There is a polyfill for older browsers here or you could switch to using the simple class manipulation functions here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM