Frameset - swap columns with rows using javascript

I have a frameset with this cols attribute set to "50%, 50%" for now. I have a toggleView method that gets called after an item is clicked.

What I intend to do is change the frameset from displaying columns to rows split 50/50 again.

I tried to do removeAttribute ("cols") on the frameset, while this removes the "cols" attribute, it doesn't seem to update on the page (testing is done using firebug).

Then I would add to add the rows attribute (is it createAttribute and then setAttribute is a valid method for this?) To finish.

I am wondering if this is possible, even if deleting columns does nothing.

Thanks a lot for any help.

0


source to share


1 answer


This worked fine for me:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
  <head>
    <title>A simple frameset document</title>
    <script type="text/javascript">
      function onloadHandler() {
        setTimeout(function() {
          var myFrameset = document.getElementById("myFrameset");
          var value = myFrameset.getAttribute("cols");
          myFrameset.removeAttribute("cols");
          myFrameset.setAttribute("rows", value);
        }, 2500);
      }
    </script>
  </head>
  <frameset id="myFrameset" onload="onloadHandler()" cols="50%, 50%">
    <FRAME src="page1.htm">
    <FRAME src="page1.htm">
  </frameset>
</html>

      



Basically, it swaps 2.5 seconds after the page loads. Let me know if you need anything else, or if it doesn't work for some reason for you. I've only tested it in IE7 (unfortunately I have been developing an application lately).

+2


source







All Articles