document.write() in the middle of a document?

F

Frances

web.dev said:
Frances wrote:


Hiding the other frames with css is not a good solution. Consider
this, what if the user continuously selects a different product? Then
the page will continue to append a new child.

What you'll have to do is use the replaceChild method.

document.getElementById("id").appendChild(newChild, oldChild);

thank you very much for yr help.... so in order for this to work I have
to put a blank iframe there initially so I can replace it afterwards..
this is how I figured, but unfortunately having some problems...

var selItem;
var ifrCurr;
var div = document.getElementById("divPricing");
// this var not being read inside functions..
// (even if I take out 'var' from declaration..)

function currIF() { // to put a blank iframe..
ifrCurr = document.createElement("iframe");
ifrCurr.src = 'iframes/blank.html';
//div.appendChild(ifrCurr); // ****** var not being read...

document.getElementById("divPricing").appendChild(ifrCurr);
// errror on this line
// is null or not an obj... (??)
// no problem w/this line in below function..
}
window.onload=currIF();

function pricing() {
selItem = document.getElementById("product").value;
var ifr = document.createElement("iframe");
ifr.src = 'iframes/' + selItem + '.html';
ifr.scrolling = 'no';
ifr.style.borderWidth='0';
ifr.setAttribute(selItem, name);
document.getElementById("divPricing").appendChild(ifr);
// div.appendChild(ifr); // ******* var not being read...

// document.getElementById("divPricing").replaceChild(ifr,ifrCurr);
// can't use this line yet b/c problems w/function above....
}

thank you very much........ Frances
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top