3

I am having troubles getting Selectivizr to work even with a very simple page. What did I do wrong?

http://jiewmeng.kodingen.com/playground/selectivr.html

<html>
<head>
    <link rel="stylesheet" href="selectivr.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.1/mootools-yui-compressed.js"></script>
    <!--[if (gte IE 6)&(lte IE 8)]>
      <script src="selectivizr.js"></script>
    <![endif]--> 

</head>

<body>
    <h1>Hello World</h1>
    <p>Paragraph 1</p>

    <p>Paragraph 2</p>
    <p>Paragraph 3</p>
    <p>Paragraph 4</p>
    <p>Paragraph 5</p>
    <p>Paragraph 6</p>
</body>
</html>

CSS

p:nth-child(2n+2) { color: red }
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805

2 Answers2

4

Selectivizr only works when your page is in strict mode. Because you haven't given your page a doctype declaration, it's loading in Quirks mode, which means Selectivizr hasn't loaded.

Simply add <!DOCTYPE html> before your opening html tag, and Selectivizr will work.

chris5marsh
  • 468
  • 3
  • 13
  • I had the same problem with nth-child in IE8. The above fix did not work for nth-child for me, but adding NWMatcher 1.2.5 worked. We're already using jQuery and Mootools. – Vik David Aug 16 '12 at 14:29
  • 2
    Hi Vik, what exactly does NWMatcher do and how did it help you? – Jacques Oct 03 '12 at 11:04
3

you might want to add the link to the existing css on which selectivizr is going to act.

Here is the full code you should be putting in the head in your case :

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

there are also 2 other known issues :

  • working locally, it won't work
  • working with PIE.htc it the same time, if you have uncommented it.

Hope it helps ! good luck.

laura
  • 31
  • 2
  • Hi @Laura, the point you mentioned about working locally... is that confirmed? I'm having the same nth-child issues, but working on localhost. Are you suggesting that hosting this on a proper domain albeit local, it will work? – Jacques Sep 25 '12 at 11:16