Re: Refreshing Page with executed Javascripts

Discussion in 'HTML' started by Ron Spears, Aug 10, 2003.

  1. Ron Spears

    Ron Spears Guest

    Ah, nice. Ok, how - let's say if I have (2) of these unique scripts:

    <script type="text/javascript">
    function ButtonOne()
    {
    document.write('<table border="0" cellpadding="0" cellspacing="0" ' +
    ' width=600>');
    }
    </script>

    <script type="text/javascript">
    function ButtonTwo()
    {
    document.write('<table border="0" cellpadding="0" cellspacing="0" ' +
    ' width=800>');
    }
    </script>



    As you can see they both have different table widths, and are designed
    to be positioned appropriately before the construction of a table.
    How do I implement two buttons that would call these, and cause the
    page to refresh with the designated table width?



    "Richard Hockey" <> wrote in message news:<3f35859a$0$961$>...
    > "Ron Spears" <> wrote in message
    > news:...
    > > Is there an easy way to have different javascripts called using <a
    > > href>'s buttons, and have them applied to the current HTML page?
    > >
    > > So if I press button 1, it executes Javascript 1 -- button 2, script
    > > 2, etc...

    >
    > How to call javascript functions using text links:
    >
    > <script type="text/javascript">
    > function ButtonOne()
    > {
    > alert('you clicked on button one.');
    > }
    >
    > function ButtonTwo()
    > {
    > alert('You clicked button two.');
    > }
    > </script>
    >
    > <a href="#" onClick="ButtonOne(); return false;">Button One</a>
    > <a href="#" onClick="ButtonTwo(); return false;">Button Two</a>
    >
    > You could also substitute images for the text in each link:
    >
    > <a href="#" onClick="ButtonOne(); return false;"><img
    > src="images/buttonone.gif" alt="Button One" border="0" /></a>
    > <a href="#" onClick="ButtonTwo(); return false;"><img
    > src="images/buttontwo.gif" alt="Button Two" border="0" /></a>
    >
    > You can also add rollover states by adding onMouseOver and onMouseOut events
    > for each link to change the src of the image.
     
    Ron Spears, Aug 10, 2003
    #1
    1. Advertising

  2. Ron Spears

    Evertjan. Guest

    Ron Spears wrote on 10 aug 2003 in comp.lang.javascript:

    > Ah, nice. Ok, how - let's say if I have (2) of these unique scripts:
    >
    > <script type="text/javascript">
    > function ButtonOne()
    > {
    > document.write('<table border="0" cellpadding="0" cellspacing="0" ' +
    > ' width=600>');
    >}
    > </script>
    >


    You cannot write to a page with document.write when the page is already
    showing (your button!), without destroying the whole page structure
    including the script part.

    Use innerHTML or DOM insert codes

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Aug 10, 2003
    #2
    1. Advertising

  3. Ron Spears

    Ron Spears Guest

    I am unfamiliar with those, can you please show me how to make it work
    using one of these formulas?


    Evertjan." <> wrote in message news:<Xns93D3681FDA66Beejj99@194.109.133.29>...
    > Ron Spears wrote on 10 aug 2003 in comp.lang.javascript:
    >
    > > Ah, nice. Ok, how - let's say if I have (2) of these unique scripts:
    > >
    > > <script type="text/javascript">
    > > function ButtonOne()
    > > {
    > > document.write('<table border="0" cellpadding="0" cellspacing="0" ' +
    > > ' width=600>');
    > >}
    > > </script>
    > >

    >
    > You cannot write to a page with document.write when the page is already
    > showing (your button!), without destroying the whole page structure
    > including the script part.
    >
    > Use innerHTML or DOM insert codes
     
    Ron Spears, Aug 11, 2003
    #3
  4. Ron Spears

    Evertjan. Guest

    Ron Spears wrote on 11 aug 2003 in comp.lang.javascript:
    > Evertjan." <> wrote in message
    > news:<Xns93D3681FDA66Beejj99@194.109.133.29>...
    >> Ron Spears wrote on 10 aug 2003 in comp.lang.javascript:
    >>
    >> > Ah, nice. Ok, how - let's say if I have (2) of these unique
    >> > scripts:
    >> >
    >> > <script type="text/javascript">
    >> > function ButtonOne()
    >> > {
    >> > document.write('<table border="0" cellpadding="0" cellspacing="0" '
    >> > + ' width=600>');
    >> >}
    >> > </script>
    >> >

    >>
    >> You cannot write to a page with document.write when the page is
    >> already showing (your button!), without destroying the whole page
    >> structure including the script part.
    >>
    >> Use innerHTML or DOM insert codes

    > I am unfamiliar with those, can you please show me how to make it work
    > using one of these formulas?


    [please do not underquote]

    ============= test.html ==========

    <script type="text/javascript">
    function ButtonOne() {
    mydivid=document.getElementById("mydiv")
    mydivid.innerHTML=''+
    '<table border="1" cellpadding="0"cellspacing="0" '+
    ' width="200px">'+
    '<tr><td>Hi</td></tr>'+
    '<tr><td>World</td></tr></table>'
    }
    </script>

    <button onclick="ButtonOne()">click</button>
    <div id=mydiv>this will be replaced</div>

    ========================

    tested IE6

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Aug 11, 2003
    #4
  5. Ron Spears

    Grant Wagner Guest

    To add content to an existing page requires a variety of code to support various browsers. An example that
    supports IE, Netscape 4, Netscape 7 and Opera 7 (and possibly other more modern browsers such as Konqueror) is
    available at:

    <url: http://jibbering.com/faq/#FAQ4_15 />

    Ron Spears wrote:

    > I am unfamiliar with those, can you please show me how to make it work
    > using one of these formulas?
    >
    > Evertjan." <> wrote in message news:<Xns93D3681FDA66Beejj99@194.109.133.29>...
    > > Ron Spears wrote on 10 aug 2003 in comp.lang.javascript:
    > >
    > > > Ah, nice. Ok, how - let's say if I have (2) of these unique scripts:
    > > >
    > > > <script type="text/javascript">
    > > > function ButtonOne()
    > > > {
    > > > document.write('<table border="0" cellpadding="0" cellspacing="0" ' +
    > > > ' width=600>');
    > > >}
    > > > </script>
    > > >

    > >
    > > You cannot write to a page with document.write when the page is already
    > > showing (your button!), without destroying the whole page structure
    > > including the script part.
    > >
    > > Use innerHTML or DOM insert codes


    --
    | Grant Wagner <>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    * http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html
    * Internet Explorer DOM Reference available at:
    * http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp
    * Netscape 6/7 DOM Reference available at:
    * http://www.mozilla.org/docs/dom/domref/
    * Tips for upgrading JavaScript for Netscape 7 / Mozilla
    * http://www.mozilla.org/docs/web-developer/upgrade_2.html
     
    Grant Wagner, Aug 12, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luigi
    Replies:
    2
    Views:
    519
    Eliyahu Goldin
    May 22, 2006
  2. Harlan Messinger

    Self-refreshing and non-self-refreshing controls

    Harlan Messinger, Aug 4, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    460
    =?Utf-8?B?Y2xpY2tvbg==?=
    Aug 4, 2006
  3. Harlan Messinger

    Self-refreshing and non-self-refreshing controls

    Harlan Messinger, Aug 3, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    189
    Harlan Messinger
    Aug 3, 2006
  4. Replies:
    2
    Views:
    134
  5. Husain
    Replies:
    3
    Views:
    181
    Thomas 'PointedEars' Lahn
    Apr 14, 2008
Loading...

Share This Page