![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Programming Guru
![]() |
DOM (createElement issue...)
This script if used on a website would not make anyone want to come back, it's purely an education attempt to refresh my knowledge...
[html]<html> <head> <title>JavaScript DOC test...</title> <style type="text/css"> #footer { font-family: Arial; font-size: 10pt; text-align: center; width: 100%; height: 20px; background-color: blue; color: white; } #footer.p { vertical-align: middle; } </style> <script type="text/javascript"> var footerDiv, footerDivText = "Copyright © 2005. All rights to this are fake..."; window.onload = function() { footerDiv = document.createElement("div"); footerDiv.id = "footer"; var footerDivP = document.createElement("p"); footerDivP.innerHTML = footerDivText; footerDiv.appendChild(footerDivText); setPos(); document.body.appendChild(footerDiv); } window.onchange = setPos; window.onscroll = setPos; function setPos() { footerDiv.style.position = "relative"; footerDiv.style.top = window.innerHeight - footerDiv.style.height - (screen.height - screen.availHeight); } </script> </head> <body> </body> </html>[/html] Mozilla FireFox's Javascript debugger gives me the following error... Quote:
footerDiv.appendChild(footerDivText); I've been looking it over numerous times, and this should work perfectly.
__________________
|
|
|
|
|
|
|
#2 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
You are trying to convert a string to a dom element. You can use
footerDiv.appendChild(document.createTextNode(footerDivText)); I don't know why the code tags keep putting a space in a random place...
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
Ooooh, oops, should have been "footerDivP"... thanks Dameon
__________________
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|