Geachte tweakers,
Ik heb weer eens iets gemaakt wat weer niet werkt in IE...
De bedoeling is dat de remaining chars in de form worden weergegeven op de achtergrond. Zie http://hqweb.nl/index.php?page=article&p=59
In ff wordt alles keurig weergeven echter in IE een groot wit blok...
Hieronder even de code (ter info)
Het heeft even wat uitleg nodig, in het textfield moet dus op de "achtergrond" de remaining chars komen...nu werken css, js en html keurig samen in FF, IE is echter drama.
Het lukt mij dus niet om dit werkend te krijgen in IE, na veel fora bezoeken en de GoT zoekfunctie ook niks gevonden dus vraag het toch maar...
mijn dank is groot
Ik heb weer eens iets gemaakt wat weer niet werkt in IE...
De bedoeling is dat de remaining chars in de form worden weergegeven op de achtergrond. Zie http://hqweb.nl/index.php?page=article&p=59
In ff wordt alles keurig weergeven echter in IE een groot wit blok...
Hieronder even de code (ter info)
Cascading Stylesheet:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| /* The position of the parent is made relative so that absolutely positioned elements take their location from this */ .charcounter { position: relative; width: 350px; height: 100px; } /* Make both the counter div and the textarea inside the div bigger and show up on top of each other by placing them on top left corner with absolute positioning */ .charcounter * { width: 350px; height: 100px; position: absolute; top: 0; left: 0; background:none transparent; } /* Modify the counter div's font to show up in the middle and with bigger letters */ .charcounter div { float: left; color: #000; font-family: Arial; font-size: 550%; font-weight: bold; text-align: center; line-height: 100px; text-align: center; vertical-align: middle; filter:alpha(opacity=50); opacity: 0.5; } /* Finally, we want the counter to change color when it's negative */ .charcounter div.negative { color: #00008B; } |
JavaScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| //We want this to run as soon as the page has loaded window.onload = function() { //Character limit var limit = 140; //the div to contain the background and the textarea var div = document.createElement('div'); div.className = 'charcounter'; //Append the div into the document before the textarea, so that when we //remove the textarea, it can be inserted inside the div and it'll look like it never moved. var txt = document.getElementById('text'); txt.parentNode.insertBefore(div, txt); //this will contain the background numbers var counter = document.createElement('div'); div.appendChild(counter); counter.innerHTML = limit; //Add both keypress and keydown handlers to make sure the event always fires txt.onkeypress = txt.onkeydown = function() { //Calculate how many chars the user has remaining var len = limit - txt.value.length; if(len < 0) { counter.className = 'negative'; } else { counter.className = ''; } counter.innerHTML = len; }; txt.parentNode.removeChild(txt); div.appendChild(txt); } |
Het heeft even wat uitleg nodig, in het textfield moet dus op de "achtergrond" de remaining chars komen...nu werken css, js en html keurig samen in FF, IE is echter drama.
Het lukt mij dus niet om dit werkend te krijgen in IE, na veel fora bezoeken en de GoT zoekfunctie ook niks gevonden dus vraag het toch maar...
mijn dank is groot
[ Voor 6% gewijzigd door JefSnare op 27-10-2009 11:47 ]