Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 1st, 2005, 6:36 PM   #1
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
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 &copy; 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:
Error: uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMHTMLDivElement.appendChild]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: file:///home/tempest/test.html :: anonymous :: line 31" data: no]
This has to do with the line:
footerDiv.appendChild(footerDivText);

I've been looking it over numerous times, and this should work perfectly.
__________________

tempest is offline   Reply With Quote
Old Nov 1st, 2005, 6:48 PM   #2
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
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
Dameon is offline   Reply With Quote
Old Nov 1st, 2005, 6:50 PM   #3
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
Ooooh, oops, should have been "footerDivP"... thanks Dameon
__________________

tempest is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:15 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC