getting 'has no properties' error with document.write()....

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

    #1

    getting 'has no properties' error with document.write()....

    function saveState() {
    document.write (" | <a href = 'myhomepage.asp ?
    view=mhp&amp;ac tion=save&amp;p b=");[color=blue][color=green]
    >> document.write (document.phone .style.display. value);[/color][/color]
    document.write ("'>save view</a>");

    };


    creates an error at this (>) line.



    function showhide (item) {
    var objid = document.getEle mentById(item);
    var imgid = document.getEle mentById(item+' i');
    var imgidMinusSrc = '/images/furniture/minus.gif';
    var imgidPlusSrc = '/images/furniture/plus2.gif';
    if (objid.style.di splay == 'inline') {
    objid.style.dis play = 'none';
    imgid.src = imgidPlusSrc;
    if (item == 'hpleftcolhl') {
    objid.style.wid th = '4px';
    document.getEle mentById('hplef tcol').style.wi dth = '6px';
    document.getEle mentById('showt ime').style.dis play =
    'none';
    }
    }
    else {
    objid.style.dis play = 'inline';
    imgid.src = imgidMinusSrc;
    if (item == 'hpleftcolhl') {
    objid.style.wid th = '160px';
    document.getEle mentById('hplef tcol').style.wi dth =
    '160px';
    document.getEle mentById('showt ime').style.dis play =
    'inline';
    }
    }
    };


    this one however works fine, and both use the same object?
    I've tried using document.getEle mentById('phone ').style.displa y
    but with same result.

    now, the saveState function is simply some inline script to build an <a
    href> , whereas the showhide one is triggered from an onclick.
  • Martin Honnen

    #2
    Re: getting 'has no properties' error with document.write( )....



    s_m_b wrote:
    [color=blue]
    > function saveState() {
    > document.write (" | <a href = 'myhomepage.asp ?
    > view=mhp&amp;ac tion=save&amp;p b=");
    >[color=green][color=darkred]
    >>> document.write (document.phone .style.display. value);[/color][/color]
    >
    > document.write ("'>save view</a>");
    >
    > };
    >
    >
    > creates an error at this (>) line.[/color]

    If the function is executed after the page has been loaded the first
    document.write clears the existing page and then document.phone does no
    longer exist. Thus the problem is likely that you use document.write
    after the page has been loaded.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • Lee

      #3
      Re: getting 'has no properties' error with document.write( )....

      s_m_b said:[color=blue]
      >
      >function saveState() {
      > document.write (" | <a href = 'myhomepage.asp ?
      >view=mhp&amp;a ction=save&amp; pb=");[color=green][color=darkred]
      >>> document.write (document.phone .style.display. value);[/color][/color]
      > document.write ("'>save view</a>");
      >
      > };
      >
      >
      >creates an error at this (>) line.[/color]

      document.write( ) clears the current contents of the document,
      so by that second line, document.phone no longer exists.

      Comment

      • s_m_b

        #4
        Re: getting 'has no properties' error with document.write( )....

        Lee <REM0VElbspamtr ap@cox.net> wrote in news:d0mv9j01lc 7@drn.newsguy.c om:
        [color=blue]
        > s_m_b said:[color=green]
        >>
        >>function saveState() {
        >> document.write (" | <a href = 'myhomepage.asp ?
        >>view=mhp&amp; action=save&amp ;pb=");[color=darkred]
        >>>> document.write (document.phone .style.display. value);[/color]
        >> document.write ("'>save view</a>");
        >>
        >> };
        >>
        >>
        >>creates an error at this (>) line.[/color]
        >
        > document.write( ) clears the current contents of the document,
        > so by that second line, document.phone no longer exists.
        >
        >[/color]

        hum.....
        would window.document .url = ...
        be an alternative for getting the page to reload?

        Comment

        • kaeli

          #5
          Re: getting 'has no properties' error with document.write( )....

          In article <Xns96149A99BF3 1Fsmb2000nshotr mailcom@216.196 .97.138>,
          smb20002ns@hotm ail.com enlightened us with...[color=blue][color=green]
          >>[/color]
          > hum.....
          > would window.document .url = ...
          > be an alternative for getting the page to reload?[/color]

          Reloading will also wipe your variables. In fact, it wipes everything and
          gets the page fresh.

          But if you want it:
          window.location .reload();

          --
          --
          ~kaeli~
          Time flies like an arrow. Fruit flies like a banana.



          Comment

          • RobG

            #6
            Re: getting 'has no properties' error with document.write( )....

            s_m_b wrote:[color=blue]
            > Lee <REM0VElbspamtr ap@cox.net> wrote in news:d0mv9j01lc 7@drn.newsguy.c om:
            >
            >[color=green]
            >>s_m_b said:
            >>[color=darkred]
            >>>function saveState() {
            >>> document.write (" | <a href = 'myhomepage.asp ?
            >>>view=mhp&amp ;action=save&am p;pb=");
            >>>
            >>>>> document.write (document.phone .style.display. value);
            >>>
            >>> document.write ("'>save view</a>");
            >>>
            >>> };
            >>>
            >>>
            >>>creates an error at this (>) line.[/color]
            >>
            >>document.writ e() clears the current contents of the document,
            >>so by that second line, document.phone no longer exists.
            >>
            >>[/color]
            >
            >
            > hum.....
            > would window.document .url = ...
            > be an alternative for getting the page to reload?[/color]

            It seems that you are trying to create a URL based on current
            page settings for the user to click on. If that is the case,
            then use DOM methods to write the link, not document.write.

            Alternatively, create your HTML as one string, then write the
            entire thing in one go so that by the time document.write clears
            the page, you've already used your in-page values:


            var aHTML = ' | <a href = "myhomepage.asp ?'
            + 'view=mhp&amp;a ction=save&amp; pb='
            + document.phone. style.display.v alue
            + '">save view</a' + '>';
            document.write( aHTML);



            --
            Rob

            Comment

            Working...