0

I need to be able to support all CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8. The polyfill called selectivizr allows you to do this. It needs a javascript library such as jquery or mootools to work. The problem is that while selectivizr supports all the pseudo-classes and attribute selectors with mootools, as many as 11 of them are either not recognized or not supported with jquery. So although I have never used mootools in my life I am forced to add it to my webpage as an external script along with selectivizr in the conditional comments to detect if the webpage has been accessed from Internet Explorer 6-8 or not.

Like this:

<!--[if (gte IE 6)&(lte IE 8)]>
  <script type="text/javascript" src="mootools-core.js"></script>
  <script type="text/javascript" src="selectivizr.js"></script>
  <noscript><link rel="stylesheet" href="[fallback css]" /></noscript>
<![endif]-->

The problem is that mootools and jquery have been known to conflict with each other. My webpage has lots of jquery all over it. Editing it all using jQuery.noConflict() is not really an option nor is wrapping all of it between

(function ($) {
    // $ is actually jQuery here
    $(document).ready(function () {

    })
}(jQuery))

Plus I don't know if so but the presence of more than one javascript libraries that selectivizr uses may cause problems with the functionality of selectivizr itself. I think what I need to do is add some mootools code to my webpage to prevent it from conflicting with jquery and at the same time make sure that selectivizr is not detected by jquery and is only able to respond to mootools. But since I have never used mootools I don't know how to do this. Can anyone help?

P.S I don't have Internet Explorer 6-8 so I can't test this so please be careful and responsible if you give an answer.

4

1 回答 1

1

Mootools 没有声明$如果其他东西已经定义了它。因此,如果您确保在 Mootools 之前加载 jQuery,那么它$仍然是 jQuery$

(即:保留 jquery<script>标记在<head>, 并且不要使用asyncordefer属性)

这确实取决于 selectivzr 本身使用document.id而不是$-document.id是 Mootools 调用“Mootools $”的替代方式

于 2017-07-24T18:59:23.113 回答