document.getElementById stopped working after adding an iframe

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AC

    document.getElementById stopped working after adding an iframe

    I had a page that does some event setup on window.onload:

    function prepEvents()
    {
    document.getEle mentById("menum ap_sales").onmo useover =
    swapMenuSales;
    // etc
    }

    window.onload = prepEvents;


    worked great, until the page where this javascript src is loaded now
    contains an iframe. It seems that the document.getEle mentById() call
    is returning null now. If I remove the iframe, it all works again.

    Presumably it's something to do with having multiple documents now,
    but how do I access the one I want?

    Thanks for your help!

    Andy C
  • SAM

    #2
    Re: document.getEle mentById stopped working after adding an iframe

    AC a écrit :
    I had a page that does some event setup on window.onload:
    >
    function prepEvents()
    {
    document.getEle mentById("menum ap_sales").onmo useover =
    swapMenuSales;
    // etc
    }
    >
    window.onload = prepEvents;
    >
    >
    worked great, until the page where this javascript src is loaded now
    contains an iframe. It seems that the document.getEle mentById() call
    is returning null now. If I remove the iframe, it all works again.
    >
    Presumably it's something to do with having multiple documents now,
    but how do I access the one I want?
    only one ID of same name in a page !

    you can't acces file loaded in iframes if this file is from another
    domain that the main file.

    Comment

    • AC

      #3
      Re: document.getEle mentById stopped working after adding an iframe

      >
      only one ID of same name in a page !
      >
      yep there are no repeated ids.
      you can't acces file loaded in iframes if this file is from another
      domain that the main file.
      agreed. Both are in the root of my site. HTML goes like this:
      <html>
      <script language="JavaS cript" type="text/javascript" src="script/
      menu.js"></script>
      <body>
      <form>
      <div id="pagebody">
      <div id="loginlinks" >
      <iframe src="chat.html" frameborder="0" scrolling="no"
      id="chatFrame" name="chatFrame " />
      </div>
      </div>
      </body>
      </html>

      Could it be something to do with timing? i.e. the onload event is
      being called before the DOM object is ready???

      I'm completely at a loss at the moment; adding an iframe should be the
      easy bit...

      Help!
      TIA,
      AC

      Comment

      • SAM

        #4
        Re: document.getEle mentById stopped working after adding an iframe

        AC a écrit :
        >only one ID of same name in a page !
        >>
        >
        yep there are no repeated ids.
        >
        >you can't acces file loaded in iframes if this file is from another
        >domain that the main file.
        >
        agreed. Both are in the root of my site. HTML goes like this:
        <html>
        <script language="JavaS cript" type="text/javascript" src="script/
        menu.js"></script>
        <body>
        <form>
        what is this opening form tag ?
        (with nowhere a closing one)
        <div id="pagebody">
        <div id="loginlinks" >
        <iframe src="chat.html" frameborder="0" scrolling="no"
        id="chatFrame" name="chatFrame " />
        </div>
        </div>
        </body>
        </html>
        >
        Could it be something to do with timing? i.e. the onload event is
        being called before the DOM object is ready???
        >
        I'm completely at a loss at the moment; adding an iframe should be the
        easy bit...

        is it the main page which gets the onload function ?

        I see nowhere the element 'menumap_sales' ... !


        --
        sm

        Comment

        • dhtml

          #5
          Re: document.getEle mentById stopped working after adding an iframe

          On Jun 30, 3:25 pm, SAM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
          wrote:
          AC a écrit :
          >
          [snip]
          you can't acces file loaded in iframes if this file is from another
          domain that the main file.
          >
          agreed.  Both are in the root of my site.  HTML goes like this:
          <html>
          Where is the head tag?

              <script language="JavaS cript" type="text/javascript" src="script/
          menu.js"></script>
              <body>
                  <form>
          >
          what is this opening form tag ?
          (with nowhere a closing one)
          >
          Good question.
                  <div id="pagebody">
                      <div id="loginlinks" >
                          <iframe src="chat.html" frameborder="0" scrolling="no"
          id="chatFrame" name="chatFrame " />
                      </div>
                  </div>
              </body>
          </html>
          >
          Could it be something to do with timing?  i.e. the onload event is
          being called before the DOM object is ready???
          >
          I'm completely at a loss at the moment; adding an iframe should be the
          easy bit...
          >
          Validate the HTML first.

          My friend who works at Yahoo came to me for help last week. All of a
          sudden things "stopped working" so she asked for my help.

          It turned out that there was another developer who "owned" the
          autocomplete part of the app. Yahoo does everything in a totally
          retarded way status reports, no testing, and isolated cowboy coding.
          They call this "Scrum" and balance it out with lots of middle
          management.

          The autocomplete code had something along the lines of:

          document.body.i nnerHTML = "<div id='wrapper'>" +
          document.body.i nnerHTML +
          "</div>";

          This caused the problem of all nodes refs being wiped out, so where
          she had:-

          var button = document.getEle mentById('butto n'),
          title = document.getEle mentById('title ');
          bar.onclick = function() {
          // Error: title is null or not an object
          title.style.dis play = "";

          </script>

          <script src="autocomple te.js"></script>

          An IFRAME is perfectly capable of adding such scripts to the page, and
          it's entirely possible that your iframe has a script that does that.

          Garrett
          is it the main page which gets the onload function ?
          >
          I see nowhere the element 'menumap_sales' ... !
          >
          Yeah. Post the real code.
          --
          sm

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: document.getEle mentById stopped working after adding an iframe

            dhtml wrote:
            On Jun 30, 3:25 pm, SAM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
            wrote:
            >AC a écrit :
            >>>you can't acces file loaded in iframes if this file is from another
            >>>domain that the main file.
            >>agreed. Both are in the root of my site. HTML goes like this:
            >><html>
            >
            Where is the head tag?
            The `<head>' start tag of the `head' _element type_ is optional, as is the
            `</head>' end tag of the same.

            <http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#h-7.4.1>
            <http://www.w3.org/TR/1999/REC-html401-19991224/index/elements.html>
            >> <script language="JavaS cript" type="text/javascript" src="script/
            >>menu.js"></script>
            >> <body>
            >> <form>
            >what is this opening form tag ?
            >(with nowhere a closing one)
            >
            Good question.
            It is not Valid, the required `action' attribute is missing.

            <http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-FORM>

            But in this case both appear to be unnecessary.
            My friend who works at Yahoo came to me for help last week. All of a
            sudden things "stopped working" so she asked for my help.
            >
            It turned out that there was another developer who "owned" the
            autocomplete part of the app. Yahoo does everything in a totally
            retarded way status reports, no testing, and isolated cowboy coding.
            They call this "Scrum" and balance it out with lots of middle
            management.
            If true, this would shed some serious doubt about the code quality of YUI.
            (I should probably peer-review it soon.)


            PointedEars
            --
            Anyone who slaps a 'this page is best viewed with Browser X' label on
            a Web page appears to be yearning for the bad old days, before the Web,
            when you had very little chance of reading a document written on another
            computer, another word processor, or another network. -- Tim Berners-Lee

            Comment

            • AC

              #7
              Re: document.getEle mentById stopped working after adding an iframe


              OK here's all the code (I'd omitted repetitions and the obvious bits
              for brevity). It's come from an ASP.net page so you'll have to work
              around the asp bits I'm afraid...

              [HTML]

              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
              www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
              <html xmlns="http://www.w3.org/1999/xhtml">
              <head runat="server">
              <title>Page title</title>
              <link href="ActiveSty le.css" rel="stylesheet " type="text/css" />
              <link href="MenuStyle .css" rel="stylesheet " type="text/css" />
              <script language="JavaS cript" type="text/javascript" src="script/
              menu.js"></script>
              </head>
              <body>
              <form id="form1" runat="server">
              <div id="pagebody">
              <div id="logo">
              <asp:Image ID="imgLogo" runat="server"
              EnableTheming=" False"
              EnableViewState ="False" ImageUrl="~/images/
              BITS_200x123.pn g" />
              </div>
              <div id="loginlinks" >
              <asp:Literal ID="litDate" runat="server"
              EnableViewState ="False" Mode="PassThrou gh"></asp:Literal><br />
              <!--
              * * * * * * * * * * * * * * * * * * * * * *
              *
              * this is the iframe that breaks the javascript....
              *
              <iframe src="chat.html" frameborder="0" scrolling="no"
              id="chatFrame" name="chatFrame " /-->
              *
              * * * * * * * * * * * * * * * * * * * * * *
              </div>
              <div id="navmenu">
              <img src="images/menu.png" id="navmenuimg "
              usemap="#menuma p" alt="Main menu" />
              <map name="menumap" id="menumap" >
              <area shape="rect" coords="0,0,140 ,20" href="#"
              id="menumap_ite m1" alt="1" />
              <area shape="rect" coords="0,21,14 0,40" href="#"
              id="menumap_ite m2" alt="2" />
              <area shape="rect" coords="0,41,14 0,60" href="#"
              id="menumap_ite m3" alt="3" />
              <area shape="rect" coords="0,61,14 0,80" href="#"
              id="menumap_ite m4" alt="4" />
              <area shape="rect" coords="0,101,1 40,120" href="#"
              id="menumap_ite m5" alt="5" />
              </map>
              </div>
              <div class="navmenu_ spacer_top">
              </div>
              <div id="navmenu_ite m1" class="navmenu_ sub1">
              <a href="#" name="navmenu_i tem1_0_link"
              id="navmenu_ite m1_0_link" onmouseover="sw apMenu('navmenu _item1_0_img',
              item1Images[0][1].src);" onmouseout="swa pMenu('navmenu_ item1_0_img',
              item1Images[0][0].src);"><img src="images/menu_item1_0.pn g"
              id="navmenu_ite m1_0_img" alt="1.1" title="1.1" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem1_1_link"
              id="navmenu_ite m1_1_link" onmouseover="sw apMenu('navmenu _item1_1_img',
              item1Images[1][1].src);" onmouseout="swa pMenu('navmenu_ item1_1_img',
              item1Images[1][0].src);"><img src="images/menu_item1_1.pn g"
              id="navmenu_ite m1_1_img" alt="1.2" title="1.2" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem1_2_link"
              id="navmenu_ite m1_2_link" onmouseover="sw apMenu('navmenu _item1_2_img',
              item1Images[2][1].src);" onmouseout="swa pMenu('navmenu_ item1_2_img',
              item1Images[2][0].src);"><img src="images/menu_item1_2.pn g"
              id="navmenu_ite m1_2_img" alt="1.3" title="1.3" /></a><a href="#"></a>
              </div>
              <div class="navmenu_ spacer">
              </div>
              <div id="navmenu_ite m2" class="navmenu_ sub1">
              <a href="#" name="navmenu_i tem2_0_link"
              id="navmenu_ite m2_0_link" onmouseover="sw apMenu('navmenu _item2_0_img',
              item2Images[0][1].src);" onmouseout="swa pMenu('navmenu_ item2_0_img',
              item2Images[0][0].src);"><img src="images/menu_item2_0.pn g"
              id="navmenu_ite m2_0_img" alt="2.1" title="2.1" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem2_1_link"
              id="navmenu_ite m2_1_link" onmouseover="sw apMenu('navmenu _item2_1_img',
              item2Images[1][1].src);" onmouseout="swa pMenu('navmenu_ item2_1_img',
              item2Images[1][0].src);"><img src="images/menu_item2_1.pn g"
              id="navmenu_ite m2_1_img" alt="2.2" title="2.2" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem2_2_link"
              id="navmenu_ite m2_2_link" onmouseover="sw apMenu('navmenu _item2_2_img',
              item2Images[2][1].src);" onmouseout="swa pMenu('navmenu_ item2_2_img',
              item2Images[2][0].src);"><img src="images/menu_item2_2.pn g"
              id="navmenu_ite m2_2_img" alt="2.3" title="2.3" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem2_3_link"
              id="navmenu_ite m2_3_link" onmouseover="sw apMenu('navmenu _item2_3_img',
              item2Images[3][1].src);" onmouseout="swa pMenu('navmenu_ item2_3_img',
              item2Images[3][0].src);"><img src="images/menu_item2_3.pn g"
              id="navmenu_ite m2_3_img" alt="2.4" title="2.4" /></a><a href="#"></a>
              </div>
              <div class="navmenu_ spacer">
              </div>
              <div id="navmenu_ite m3" class="navmenu_ sub1">
              <a href="#" name="navmenu_i tem3_0_link"
              id="navmenu_ite m3_0_link" onmouseover="sw apMenu('navmenu _item3_0_img',
              item3Images[0][1].src);" onmouseout="swa pMenu('navmenu_ item3_0_img',
              item3Images[0][0].src);"><img src="images/menu_item3_0.pn g"
              id="navmenu_ite m3_0_img" alt="3.1" title="3.1" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem3_1_link"
              id="navmenu_ite m3_1_link" onmouseover="sw apMenu('navmenu _item3_1_img',
              item3Images[1][1].src);" onmouseout="swa pMenu('navmenu_ item3_1_img',
              item3Images[1][0].src);"><img src="images/menu_item3_1.pn g"
              id="navmenu_ite m3_1_img" alt="3.2" title="3.2" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem3_2_link"
              id="navmenu_ite m3_2_link" onmouseover="sw apMenu('navmenu _item3_2_img',
              item3Images[2][1].src);" onmouseout="swa pMenu('navmenu_ item3_2_img',
              item3Images[2][0].src);"><img src="images/menu_item3_2.pn g"
              id="navmenu_ite m3_2_img" alt="3.3" title="3.3" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem3_3_link"
              id="navmenu_ite m3_3_link" onmouseover="sw apMenu('navmenu _item3_3_img',
              item3Images[3][1].src);" onmouseout="swa pMenu('navmenu_ item3_3_img',
              item3Images[3][0].src);"><img src="images/menu_item3_3.pn g"
              id="navmenu_ite m3_3_img" alt="3.4" title="3.4" /></a><a href="#"></a>
              </div>
              <div class="navmenu_ spacer">
              </div>
              <div id="navmenu_ite m4" class="navmenu_ sub1">
              <a href="#" name="navmenu_i tem4_0_link"
              id="navmenu_ite m4_0_link" onmouseover="sw apMenu('navmenu _item4_0_img',
              item4Images[0][1].src);" onmouseout="swa pMenu('navmenu_ item4_0_img',
              item4Images[0][0].src);"><img src="images/menu_item4_0.pn g"
              id="navmenu_ite m4_0_img" alt="4.1" title="4.1" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem4_1_link"
              id="navmenu_ite m4_1_link" onmouseover="sw apMenu('navmenu _item4_1_img',
              item4Images[1][1].src);" onmouseout="swa pMenu('navmenu_ item4_1_img',
              item4Images[1][0].src);"><img src="images/menu_item4_1.pn g"
              id="navmenu_ite m4_1_img" alt="4.2" title="4.2" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem4_2_link"
              id="navmenu_ite m4_2_link" onmouseover="sw apMenu('navmenu _item4_2_img',
              item4Images[2][1].src);" onmouseout="swa pMenu('navmenu_ item4_2_img',
              item4Images[2][0].src);"><img src="images/menu_item4_2.pn g"
              id="navmenu_ite m4_2_img" alt="4.3" title="4.3" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem4_3_link"
              id="navmenu_ite m4_3_link" onmouseover="sw apMenu('navmenu _item4_3_img',
              item4Images[3][1].src);" onmouseout="swa pMenu('navmenu_ item4_3_img',
              item4Images[3][0].src);"><img src="images/menu_item4_3.pn g"
              id="navmenu_ite m4_3_img" alt="4.4" title="4.4" /></a><a href="#"></a>
              <a href="#" name="navmenu_i tem4_4_link"
              id="navmenu_ite m4_4_link" onmouseover="sw apMenu('navmenu _item4_4_img',
              item4Images[4][1].src);" onmouseout="swa pMenu('navmenu_ item4_4_img',
              item4Images[4][0].src);"><img src="images/menu_item4_4.pn g"
              id="navmenu_ite m4_4_img" alt="4.5" title="4.5" /></a><a href="#"></a>
              </div>
              <div class="navmenu_ spacer">
              </div>
              <div id="navmenu_bla nk" class="navmenu_ sub1">
              </div>
              <div class="navmenu_ spacer">
              </div>
              <div id="navmenu_ite m5" class="navmenu_ sub1">
              <img src="images/menu_item5_0.pn g"
              id="navmenu_ite m5_0_img" alt="Main contact phone number" title="Main
              contact phone number" /><a href="#"></a>
              <img src="images/menu_item5_1.pn g"
              id="navmenu_ite m5_1_img" alt="Main fax number" title="Main fax
              number" /><a href="#"></a>
              <a href="#" name="navmenu_i tem5_2_link"
              id="navmenu_ite m5_2_link" onmouseover="sw apMenu('navmenu _item5_2_img',
              item5Images[2][1].src);" onmouseout="swa pMenu('navmenu_ item5_2_img',
              item5Images[2][0].src);"><img src="images/menu_item5_2.pn g"
              id="navmenu_ite m5_2_img" alt="Enquiries email address"
              title="Enquirie s email address" /></a><a href="#"></a>
              <img src="images/menu_item5_3.pn g"
              id="navmenu_ite m5_3_img" alt="Out of hours mobile" title="Out of hours
              mobile" /><a href="#"></a>
              </div>
              <div id="pagecontent ">
              <asp:ContentPla ceHolder id="PageContent PlaceHolder"
              runat="server" >
              </asp:ContentPlac eHolder>
              </div>
              </div>
              </form>
              </body>
              </html>

              [/HTML]

              [chat.html]
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
              www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
              <html xmlns="http://www.w3.org/1999/xhtml">
              <head>
              <title>Whatever </title>
              <link href="ActiveSty le.css" rel="stylesheet " type="text/css" />
              </head>
              <body>
              <h1>Whatever</h1>
              </body>
              </html>

              [/chat.html]

              [menu.js]
              function getElementsByCl ass(searchClass , node, tag)
              {
              var classElements = new Array();

              if (node == null)
              node = document;

              if (tag == null)
              tag = '*';

              var els = node.getElement sByTagName(tag) ;
              var elsLen = els.length;
              var pattern = new RegExp("(^|\\s) " + searchClass + "(\\s|$)");
              for (i = 0, j = 0; i < elsLen; i++)
              {
              if (pattern.test(e ls[i].className) )
              {
              classElements[j] = els[i];
              j++;
              }
              }

              return classElements;
              }



              function showGeneric(tar getClass, targetId)
              {
              var i;
              var classElements = getElementsByCl ass(targetClass ,
              document.form1) ;

              // hide all of these
              for (i = 0; i < classElements.l ength; i++)
              classElements[i].style.visibili ty = "hidden";

              if (targetId)
              {
              // find the one we're interested in showing
              var targetElem = document.getEle mentById(target Id);
              if (targetElem)
              targetElem.styl e.visibility = "visible";
              }
              }

              function swapMenu(target Id, srcUrl)
              {
              var targetObj = document.getEle mentById(target Id);
              if (targetObj)
              targetObj.src = srcUrl;
              }

              function swapMenuImage(m enuImageUrl, menuId, subMenuId, subMenuClass)
              {
              swapMenu(menuId , menuImageUrl);
              showGeneric(sub MenuClass, subMenuId);
              }

              function createMenuArray (normalUrl, hoverUrl)
              {
              var arrayOut = new Array(2);

              arrayOut[0] = new Image();
              arrayOut[1] = new Image();
              arrayOut[0].src = normalUrl;
              arrayOut[1].src = hoverUrl;

              return arrayOut;
              }

              function preLoadImages()
              {
              imgItem1 = new Image();
              imgItem2 = new Image();
              imgItem3 = new Image();
              imgItem4 = new Image();
              imgItem5 = new Image();

              // main menu
              imgItem1.src = "images/menu_item1.png" ;
              imgItem2.src = "images/menu_item2.png" ;
              imgItem3.src = "images/menu_item3.png" ;
              imgItem4.src = "images/menu_item4.png" ;
              imgItem5.src = "images/menu_item5.png" ;

              // first menu
              item1Images = new Array();
              item1Images[0] = createMenuArray ("images/menu_item1_0.pn g",
              "images/menu_item1_0_ho ver.png");
              item1Images[1] = createMenuArray ("images/menu_item1_1.pn g",
              "images/menu_item1_1_ho ver.png");
              item1Images[2] = createMenuArray ("images/menu_item1_2.pn g",
              "images/menu_item1_2_ho ver.png");

              // second menu
              item2Images = new Array();
              item2Images[0] = createMenuArray ("images/menu_item2_0.pn g",
              "images/menu_item2_0_ho ver.png");
              item2Images[1] = createMenuArray ("images/menu_item2_1.pn g",
              "images/menu_item2_1_ho ver.png");
              item2Images[2] = createMenuArray ("images/menu_item2_2.pn g",
              "images/menu_item2_2_ho ver.png");
              item2Images[3] = createMenuArray ("images/menu_item2_3.pn g",
              "images/menu_item2_3_ho ver.png");

              // third menu
              item3Images = new Array();
              item3Images[0] = createMenuArray ("images/menu_item3_0.pn g",
              "images/menu_item3_0_ho ver.png");
              item3Images[1] = createMenuArray ("images/menu_item3_1.pn g",
              "images/menu_item3_1_ho ver.png");
              item3Images[2] = createMenuArray ("images/menu_item3_2.pn g",
              "images/menu_item3_2_ho ver.png");
              item3Images[3] = createMenuArray ("images/menu_item3_3.pn g",
              "images/menu_item3_3_ho ver.png");

              // forth menu
              item4Images = new Array();
              item4Images[0] = createMenuArray ("images/menu_item4_0.pn g",
              "images/menu_item4_0_ho ver.png");
              item4Images[1] = createMenuArray ("images/menu_item4_1.pn g",
              "images/menu_item4_1_ho ver.png");
              item4Images[2] = createMenuArray ("images/menu_item4_2.pn g",
              "images/menu_item4_2_ho ver.png");
              item4Images[3] = createMenuArray ("images/menu_item4_3.pn g",
              "images/menu_item4_3_ho ver.png");
              item4Images[4] = createMenuArray ("images/menu_item4_4.pn g",
              "images/menu_item4_4_ho ver.png");

              // fifth menu
              item5Images = new Array();
              item5Images[0] = new Image();
              item5Images[0].src = "images/menu_item5_0.pn g";
              item5Images[1] = new Image();
              item5Images[1].src = "images/menu_item5_0.pn g";
              item5Images[2] = createMenuArray ("images/menu_item5_2.pn g",
              "images/menu_item5_2_ho ver.png");
              item5Images[3] = new Image();
              item5Images[3].src = "images/menu_item5_0.pn g";
              item5Images[4] = new Image();
              item5Images[4].src = "images/menu_item5_0.pn g";

              }

              function swapMenu1()
              {
              swapMenuImage(i mgItem1.src, "navmenuimg ", "navmenu_item1" ,
              "navmenu_sub1") ;
              }

              function swapMenu2()
              {
              swapMenuImage(i mgItem2.src, "navmenuimg ", "navmenu_item2" ,
              "navmenu_su b1")
              }

              function swapMenu3()
              {
              swapMenuImage(i mgItem3.src, "navmenuimg ", "navmenu_item3" ,
              "navmenu_sub1") ;
              }

              function swapMenu4()
              {
              swapMenuImage(i mgItem4.src, "navmenuimg ", "navmenu_item4" ,
              "navmenu_su b1")
              }

              function swapMenu5()
              {
              swapMenuImage(i mgItem5.src, "navmenuimg ", "navmenu_item5" ,
              "navmenu_su b1")
              }

              function prepEvents()
              {
              // main menu
              document.getEle mentById("menum ap_item1").onmo useover = swapMenu1;
              document.getEle mentById("menum ap_item2").onmo useover = swapMenu2;
              document.getEle mentById("menum ap_item3").onmo useover = swapMenu3;
              document.getEle mentById("menum ap_item4").onmo useover = swapMenu4;
              document.getEle mentById("menum ap_item5").onmo useover = swapMenu5;

              }

              function windowLoad()
              {
              preLoadImages() ;
              prepEvents();
              }

              window.onload = windowLoad;

              [/menu.js]


              [MenuStyle.css]
              #navmenu img
              {
              border:0px;
              }

              ..navmenu_sub1
              {
              height:17px;
              visibility:hidd en;
              vertical-align:top;
              }

              ..navmenu_sub1 img
              {
              border:0px;
              }

              #navmenu_blank
              {
              }

              ..navmenu_space r_top
              {
              height:8px;
              }

              ..navmenu_space r
              {
              height:3px;
              visibility:hidd en;
              }

              [/MenuStyle.css]


              Phew!

              Thanks for the assistance,
              AC

              Comment

              • Gregor Kofler

                #8
                Re: document.getEle mentById stopped working after adding an iframe

                AC meinte:
                OK here's all the code (I'd omitted repetitions and the obvious bits
                for brevity). It's come from an ASP.net page so you'll have to work
                around the asp bits I'm afraid...
                [hundreds of lines snipped]

                Thanks for shortening. Anyway, I doubt that anybody will look into it.
                Reading phone books provides better entertainment.

                Gregor


                --
                http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
                http://web.gregorkofler.com ::: meine JS-Spielwiese
                http://www.image2d.com ::: Bildagentur für den alpinen Raum

                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: document.getEle mentById stopped working after adding an iframe

                  AC wrote:
                  OK here's all the code (I'd omitted repetitions and the obvious bits
                  for brevity).
                  I don't see anyone asking for it. Especially not me, whose posting
                  you have nonsensically replied to. Please read and take heed of
                  <http://www.jibbering.c om/faq/#FAQ2_3>.
                  It's come from an ASP.net page so you'll have to work
                  around the asp bits I'm afraid...
                  You will have to work through it by yourself, I'm afraid. Understand that
                  there is no point in your posting server-side code if you have a client-side
                  problem like this one.

                  And there is no point in serving XHTML to a UA that does not support it,
                  like MSHTML. (However, I don't know if XHTML is a requirement for ASP .NET.)
                  [more than 400 lines of almost completely uncommented source code]
                  Phew!
                  Yes, indeed. You must be kidding (and badly at that), dumping core here.
                  Thanks for the assistance,
                  ISTM you are looking for someone to do your homework, in their
                  free time, for free. This is definitely the wrong place for that.

                  <http://catb.org/~esr/faqs/smart-questions.html>


                  PointedEars
                  --
                  Use any version of Microsoft Frontpage to create your site.
                  (This won't prevent people from viewing your source, but no one
                  will want to steal it.)
                  -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

                  Comment

                  • AC

                    #10
                    Re: document.getEle mentById stopped working after adding an iframe

                    I don't know if you've read the original post, but it asked how to
                    reference elements when the page includes an iframe. The original code
                    was posted to demonstrate how elements were being referenced in the
                    page without an iframe, that worked. The long code was posted when it
                    was asked for. Maybe I replied to the wrong person - apologies if
                    that's the case.

                    Never mind, thanks anyway.

                    Comment

                    • SAM

                      #11
                      Re: document.getEle mentById stopped working after adding an iframe

                      AC a écrit :
                      I don't know if you've read the original post, but it asked how to
                      reference elements when the page includes an iframe.
                      Perhaps could you when you post (and answer) copy a part (significative
                      part) of the previous post.
                      As we could understand of what i's question, matter, subject ...

                      The original code
                      was posted to demonstrate how elements were being referenced in the
                      page without an iframe, that worked.
                      No, nothing was worked in previous code : no JS ... !
                      The long code was posted when it
                      was asked for. Maybe I replied to the wrong person - apologies if
                      that's the case.
                      >
                      Never mind, thanks anyway.
                      Not time by now
                      I'll try to see it this evening (6 hours)

                      But if it would have been possible to have the code seen by a browser it
                      would be much better.


                      --
                      sm

                      Comment

                      Working...