Click to See Complete Forum and Search --> : set complex content (innerHTML = ..) for NN


cul8er23
10-25-2003, 08:19 PM
Hi all,

does anyone know how to change an objects content (like innerHTML = "..." for IE) in NN? I'd be glad if I had not to do that with node ops. ;)

So, if you know something, please tell

Thanks in advance

cul8er23
10-25-2003, 09:05 PM
That is the code, working in IE:
------------------------------------------------------

<script language="JavaScript1.1">
var con;
function setHomeContent(){
deleteContent("content");
if(b.ie4)con = document.all.content; else con = document.getElementById("content");

con.innerHTML = "bla bla<br>bla bla<br>bla bla<br>bla bla<hr>...<img.."

// that bla bla is db-content (headlines and paragraphs vary, unfortunately :(

}
function deleteContent(id){
with(document){
while(getElementById(id).hasChildNodes())
{
getElementById(id).removeChild(getElementById(id).lastChild);
}
}
}
</script>

<div class="menuitem" onClick="setHomeContent()" style="cursor:pointer;">
<img src="pics/buttons/home.gif"/>
</div>

hmmm?!?!

Jona
10-25-2003, 09:32 PM
var tNode = document.createTextNode("blah blah<br>blah blah<br>blah blah blah...");
con.appendChild(tNode);


[J]ona

cul8er23
10-26-2003, 04:57 AM
Thanks Jona,
but what I need to add is complex content.

Actually the script above works for NN, too.
Problem is that the result can only be seen after changing window size!!

Can it be redrawn automatically?

Jona
10-26-2003, 07:29 PM
Microsoft invented the innerHTML property; the W3C (www.w3.org) did not, and the innerHTML property is not listed in their DOM Level 3 Core (http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html) pages, which means that it is not valid DOM scripting. I personally suggest never making use of Microsoft's non-standard innerHTML property.

Has the solution I provided worked for you at all, and what kind of information is it that cannot be written to the page in this way, but can be written via the innerHTML property?

[J]ona

cul8er23
10-27-2003, 06:47 AM
Thanks for your help Jona,

your solution works for text(and breaks). This fx() is supposed to create the text part of my home content.
Anyways, I started a new approach using an array, containing all relavant data,
like I did for other content of the site (I tried innerHTML to save me time).

form --> php in hidden frame builds JS-arrays and calls --> fx()in visible doc that changes content

There are 2 problems:

1. NN seems not to understand that: document.forms["set_home"].submit();
Is there an other/better way to load a file to a different frame, then via form?
Also I have to add a field from an additional form to the action:
document.forms["chooser"].action="some.php?s_grno="+groupNumber";
Again I there is the NN problem :(
2. The above procedure does not work for all contents (for some I have to change window
size in order to make it visible)


------------------------------------------------

<script language="JavaScript1.1">
function setHomeContent(p_homeData){
deleteContent("content");
with(document){
if(b.ie4)con = all.content; else con= getElementById("content");
var div = createElement("div");
var attrib = createAttribute("class");
attrib.nodeValue = "home_box";
div.setAttributeNode(attrib);
var elem;
for(var i=0;i<p_homeData.length;i++){
data = createTextNode(""+p_homeData[i][2]);
elem = createElement(p_homeData[i][0]);
attrib = createAttribute("class");
attrib.nodeValue = p_homeData[i][1];
elem.setAttributeNode(attrib);
elem.appendChild(data);
div.appendChild(elem);
}
con.appendChild(div);
}
setXtraNavi("no_actions");
}
function getHomeContent(){
// document.forms["eingabe"].action="results/group_refine_result.php?s_artgrnr="+gruppenNummer;
document.forms["set_home"].submit();
}
</script>

<div class="menuitem" onClick="getHomeContent()" style="cursor:pointer;">
<img src="pics/buttons/home.gif"/>
</div>
<form name="set_home" action="results/home_data.php" method="post" target="data_frame">
</form>

----------------------------------------------
// in main.php:
<body id="body" onLoad="maximizeLayers(), getHomeContent()" onResize="maximizeLayers()">

----------------------------------------------

If anyone knows the answer to the form problem it would help me al lot,
thanks!

Jona
10-27-2003, 11:49 AM
Try using a semi-colon instead of a comma in the BODY tag of main.php.

Document.forms["eingabe"] does not exist, so use document.forms[set_home"] and to set its action to something else, then try submitting it via JavaScript.

Do you have an example online?

[J]ona