Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Mar 2003
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    innerHTML won't work

    not sure if this is possible, but I am trying to replace the innerHTML of the following code, but innerHTML is not returning anything... the alert box is blank. Is it because it is just the TR tags?



    function onclick()
    {
    alert(document.all['staticHeaders'].innerHTML);
    }

    <div id="staticHeaders" name="staticHeaders" style="position:absolute">
    <tr>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=Store">Store</a></td>
    <td nowrap width="50"><a class="tablink" href="wpServSurvey.asp?Sort=Days">Service Date</a></td>
    <td width="140"><a class="tablink" href="wpServSurvey.asp?Sort=Contact">Contact</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=HomePhone">Home Phone</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=Date1">Call 1</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=Date2">Call 2</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=Date3">Call 3</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=LetterDate">Mail</a></td>

    </tr>
    </div>
    Thanks

    D--

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Shouldn't that be document.all('staticHeaders').innerHTML
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New Coder
    Join Date
    Mar 2003
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Yeah

    Yes it is.. I tried using getelement and forgot to change it back... it still won't work even with ()

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What's calling the function onclick? Besides the fact that it's a bad idea to name a function the same as an event, I don't see what calls it. Has the DIV staticHeaders fully loaded when it's called?

    document.getElementById is a method and uses the parens too

    document.getElementById('staticHeaders');
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    New Coder
    Join Date
    Mar 2003
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Clarification

    This may be a silly idea I don't know, if anyone has any better ways I would love to listen

    I have a table that is in iframe, I am trying to keep the header row in one place while the rest of the frame is able to scroll

    the header is going to change based on user information so I was going to grab the inner html of the header store it in some javascript so that every time that the user scrolls the iframe the top header of the table is displayed at the top of the iframe. does that make sense? for now I would be happy just to get the alert to work.

    here is the code

    function place_header()
    {
    alert(document.all('staticHeaders').innerHTML);
    }

    //-->
    </SCRIPT>
    </head>
    <body style="scrollbar-base-color: buttonface;" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" onscroll="place_header()">
    <input type="hidden" name="Current" id="Current" value="1">
    <input type="hidden" name="maxRecord" id="maxRecord" value="<%= iTo %>">
    <input type="hidden" name="Records" id="Records" value="<%= iRecs %>">


    <table cellSpacing="0" cellPadding="2" width="100%" bgcolor="#1e5c99" border="0" bordercolor="#C0C0C0" bordercolorlight="#C0C0C0" style="border-collapse: collapse">
    <div id="staticHeaders" name="staticHeaders" style="position:absolute">
    <tr>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=Store">Store</a></td>
    <td nowrap width="50"><a class="tablink" href="wpServSurvey.asp?Sort=Days">Service Date</a></td>
    <td width="140"><a class="tablink" href="wpServSurvey.asp?Sort=Contact">Contact</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=HomePhone">Home Phone</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=Date1">Call 1</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=Date2">Call 2</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=Date3">Call 3</a></td>
    <td nowrap><a class="tablink" href="wpServSurvey.asp?Sort=LetterDate">Mail</a></td>

    </tr>
    </div>

  • #6
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    beetle, it's my understanding that when it was introduced in IE4, document.all was an array, so that brackets would have been appropriate. later, it became a sort of getter function/object, so they switched to parentheses. as of now, i'm pretty sure that either is acceptable, but i don't really use it all that often, so i could be wrong.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #7
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    It shouldn't be legal to do function onclick since onclick DOES exist (it's declared but not defined). Function statements and variables share namespace, so if some variable name is declared, the function won't work.

    Try doing the old window.onclick=function(){} way instead.


    (Hmm, guess I was wrong:
    Code:
    Warning: redeclaration of var t
    Source File: javascript: var t;function t(){return true};[t,t()];
    Line: 1, Column: 31
    Source Code:
     var t;function t(){return true};[t,t()];
    only gives warning, not error, and the function overwrites the variable. Well, I don't think host objects behave the same, anyway.)
    Last edited by liorean; 04-02-2003 at 08:01 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #8
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    In fact, document.all is neither JSArray nor VBArray - it's a dynamic collection made to look as a native array to JS and VB. The reason it works with () wasn't intended - it's just that JScript has support for VBArray and thus can use both interfaces to it.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #9
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    i'd suggest putting the iframe in 2 row table. in the top row, you put the header information, and the bottom row has the iframe in it, and the iframe has the rest of the table in it.

    there may be a better way to do this, that doesn't use an iframe at all, but that's getting a little more complicated that needs be at the moment.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •