I've a problem with a dynamic creation of frameset and frame, I'm write these simple script:
function createframe(){
var ahead = document.head;
var mainfs = document.createElement('FRAMESET');
mainfs.setAttribute("name", "mainframeset");
mainfs.setAttribute("id", "mfs");
mainfs.setAttribute("cols", "50,*");
ahead.appendChild(mainfs);
for ( var i = 0; i < 2; i++) {
var ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", "www.facebook.it");
document.getElementById('mfs').appendChild(ifrm);
}
And put in head of blank html page, but won't work!
any suggestion?
You're appending your frameset to the head of the html file, so nothing will appear. But your function is not working, because it's not closed yet, a "}" is missing at last. Also you need to add an event Listener, like so :
window.addEventListener("load", createframe, false);
Here's a jsfiddle link for you: Try It