0

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?

4
  • Add http:// for your src link. Without http://, the browser interpretates a local source link. Commented Jul 23, 2015 at 21:12
  • thanks for the suggestion, but still it does not work! Commented Jul 23, 2015 at 21:20
  • Do you get an error? Commented Jul 23, 2015 at 21:29
  • nono nothing, no error and no warning but nothing! Commented Jul 23, 2015 at 21:34

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer!! I forgot to write the last }, but in the original code there is...I had already solved by inserting a button, but your solution seems much better ... thanks again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.