Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Re: Refreshing Page with executed Javascripts

Reply
Thread Tools

Re: Refreshing Page with executed Javascripts

 
 
Ron Spears
Guest
Posts: n/a
 
      08-10-2003
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" <(E-Mail Removed)> wrote in message news:<3f35859a$0$961$(E-Mail Removed)> ...
> "Ron Spears" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) m...
> > 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.

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      08-10-2003
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)
 
Reply With Quote
 
 
 
 
Ron Spears
Guest
Posts: n/a
 
      08-11-2003
I am unfamiliar with those, can you please show me how to make it work
using one of these formulas?


Evertjan." <(E-Mail Removed)> 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

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      08-11-2003
Ron Spears wrote on 11 aug 2003 in comp.lang.javascript:
> Evertjan." <(E-Mail Removed)> 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)
 
Reply With Quote
 
Grant Wagner
Guest
Posts: n/a
 
      08-12-2003
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." <(E-Mail Removed)> 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 <(E-Mail Removed)>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JSP and Javascripts on same page (Passing values to JSP fromJavascript) Husain Javascript 3 04-14-2008 10:36 AM
Refreshing page 1 after page 2 has been called from page 1 patrice.fiset@gmail.com Javascript 2 06-20-2007 10:13 PM
Self-refreshing and non-self-refreshing controls Harlan Messinger ASP .Net 1 08-04-2006 01:13 PM
Self-refreshing and non-self-refreshing controls Harlan Messinger ASP .Net Web Controls 0 08-03-2006 12:29 PM
Master page code executed after child page code Luigi ASP .Net 2 05-22-2006 09:53 AM



Advertisments