Ik heb in JS een mooi script geschreven (dit script moet nog groter worden, aangezien ik ook nog drag & drop wil ondersteunen):
Ik heb dit stukje getest in FF, en dit werkt goed met mijn stylesheet
IE vertikt het echter om dit goed te doen, terwijl ik met de DOM explorer wel de correcte attribuutwaarden zie. Wat ben ik hier nog vergeten? Op google of MSDN kan ik het niet vinden.
Ik roep de code op deze manier aan:
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
| // JScript File var boxes = 0; var closeText = "Close"; function Box(width, height, titleText, name) { if(!document.createTextNode) { return; } boxes++; this.Width = width; this.Height = height; this.Container = makeNewElement("div"); this.Container.setAttribute("class", name + "Box"); this.Container.setAttribute("id", "Box_" + boxes.toString()); var self = this; var title = makeNewElement("div"); var control = makeNewElement("div"); var link = makeNewElement("a"); title.appendChild(document.createTextNode(titleText)); title.setAttribute("class", "title"); link.appendChild(document.createTextNode("X")); link.setAttribute("href", "#"); link.setAttribute("title", closeText); link.onclick = function() { self.Hide(); } control.setAttribute("class", "control"); control.appendChild(link); this.Container.appendChild(title); this.Container.appendChild(control); } Box.prototype = { Show:function() { if(this.Container) { this.Container.style.visibility = "visible"; document.getElementsByTagName("body")[0].appendChild(this.Container); } }, Hide:function() { if(this.Container) { this.Container.style.visibility = "hidden"; this.Container = null; } } } function makeNewElement(element) { if(document.createElementNS) { return document.createElementNS("http://www.w3.org/1999/xhtml", element); } else if(document.createElement) { return document.createElement(element); } } var b = new Box(200, 200, "Title", ""); b.Show(); |
Ik heb dit stukje getest in FF, en dit werkt goed met mijn stylesheet
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
41
42
43
44
45
46
47
48
49
50
51
52
53
| .Box { width: 18em; background-color: Silver; float: left; display: inline; padding-bottom: 0.5em; border: #696969 1px solid; } .Box div { margin-left: 2.5%; margin-top: 0.5em; width: 95%; background-color: White; display: inline; float: left; border: silver 1px outset; } .Box .title { text-align: center; width: 75%; font-weight: bold; } .Box .control { text-align: center; width: 15%; float: right; margin-right: 1.6%; } .Box .control A { color: Red; text-decoration: none; font-weight: bold; } .Box .buttons { text-align: center; } .Box .message { height: 8em; overflow: auto; } |
IE vertikt het echter om dit goed te doen, terwijl ik met de DOM explorer wel de correcte attribuutwaarden zie. Wat ben ik hier nog vergeten? Op google of MSDN kan ik het niet vinden.
Ik roep de code op deze manier aan:
HTML:
1
2
3
4
5
6
7
8
9
10
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Page</title> <link href="App_Themes/Test/Boxes.css" rel="stylesheet" type="text/css" /> </head> <body> <script type="text/javascript" src="JScript.js"></script> </body> </html> |
[ Voor 0% gewijzigd door BasSpruit op 29-01-2007 12:45 . Reden: toevoeging ]