473,545 Members | 529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implement refresh button

I want to add a refresh button to my web page which works like browser
refresh button:
it must re-load current page from server.

How to implement this in javascript ?
Jul 20 '05 #1
6 14393
In article <3f********@new s.estpak.ee>, no************* *@online.ee
shared the illuminating thought...
I want to add a refresh button to my web page which works like browser
refresh button:
it must re-load current page from server.

How to implement this in javascript ?


<input type="button" name="btn1" onClick="docume nt.location.rel oad
(true)" value="Reload">
--
----------------------------------------
~kaeli~
There is no justification or rationalization
for mutilation. Ban declawing as inhumane.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
----------------------------------------
Jul 20 '05 #2
Andrus Moor wrote:
I want to add a refresh button to my web page which works like browser
refresh button:
it must re-load current page from server.

How to implement this in javascript ?


<a href="urlOfCurr entPage.html"
onclick="window .location.reloa d(true);return false;">Refresh </a>

or

<a href="urlOfCurr entPage.html"
onclick="window .location.href = 'urlOfCurrentPa ge.html?t=' + (new
Date()).getTime ();return false;">Refresh </a>

--
| Grant Wagner <gw*****@agrico reunited.com>

* 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 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #3
Grant Wagner wrote on 14 jul 2003 in comp.lang.javas cript:
<a href="urlOfCurr entPage.html"
onclick="window .location.reloa d(true);return false;">Refresh </a>


Why this return false ??

The page is no longer active !!!

why the true ?

This is enough, I think:

<a href="urlOfCurr entPage.html"
onclick="locati on.reload();">
Refresh
</a>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4
Evertjan. wrote on 14 jul 2003 in comp.lang.javas cript:
Grant Wagner wrote on 14 jul 2003 in comp.lang.javas cript:
<a href="urlOfCurr entPage.html"
onclick="window .location.reloa d(true);return false;">Refresh </a>


Why this return false ??

The page is no longer active !!!

why the true ?

This is enough, I think:

<a href="urlOfCurr entPage.html"
onclick="locati on.reload();">
Refresh
</a>


The second question I can answer myself:
location.reload (boolean):
false [Default]: Reloads the page from the browser cache.
true: Reloads the page from the server.

But I never saw any proof of that, does it work ????

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #5
"Evertjan." wrote:
Evertjan. wrote on 14 jul 2003 in comp.lang.javas cript:
Grant Wagner wrote on 14 jul 2003 in comp.lang.javas cript:
<a href="urlOfCurr entPage.html"
onclick="window .location.reloa d(true);return false;">Refresh </a>


Why this return false ??

The page is no longer active !!!

why the true ?

This is enough, I think:

<a href="urlOfCurr entPage.html"
onclick="locati on.reload();">
Refresh
</a>


The second question I can answer myself:

location.reload (boolean):
false [Default]: Reloads the page from the browser cache.
true: Reloads the page from the server.

But I never saw any proof of that, does it work ????


I'm not sure if window.location .reload(true) guarantees a fresh copy
from the server or not, which is why I also provided a unique URL
solution as well.

As for not returning false from the onclick. While you're right that in
most cases, it is not necessary, at least one browser (IE 5.5) navigates
(or begins to navigate to) the HREF immediately after returning from the
onclick event. As a result, the navigation to the HREF tends to cancel
any redirection you do in the onclick event. For example:

<a href="#" onclick="docume nt.forms[0].submit();">Sub mit</a>

works in almost every browser except IE 5.5, which never submits the
form.

For this reason, I always return false to the onclick event (where
applicable), even when in most cases, it will never be executed.

--
| Grant Wagner <gw*****@agrico reunited.com>

* 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 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #6
hi,
I used this code

<input type="button" name="btn1" onClick="docume nt.location.rel oad
(true)" value="Reload">

but it only works once! After I hit it once, all subsuqunet hits just
keep showing old data. Does it anyone what is wrong?

Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4904
by: Mark | last post by:
I have a working PHP/MySQL application used for data entry. The data entry screen includes a "Save" button. The PHP code for this button looks like this: if (isset($_POST)) { if ($_POST == "") { include ("InsertRecord.inc"); // Insert new record }
4
3152
by: Andrew Alger | last post by:
ok i have two forms. Customer.aspx and Parent_Searh.aspx. There is a button on Customer.aspx that when executed runs javascript code to open up parent_search as a popup. After the user searches for the parent and finds the proper parent in the datagrid they then click on the accept button in the grid. Then I populate a session variable...
6
3317
by: laura | last post by:
I'm doing a page which gathers some text in the form of a text box in a <form>. This text is saved to a text file, notices.txt and I want to be able to display the saved text on the page, as soon as they click the SUBMIT button - is this possible? At the moment I have a hyperlink called "back" which, once they have entered the text and they...
10
9228
by: tasmisr | last post by:
This is an old problem,, but I never had it so bad like this before,, the events are refiring when clicking the Browser refresh button. In the Submit button in my webform, I capture the server side click event and I update session information to track the visibilty of some panels in a wizard type navigation ("Next >>" and "<< Back" buttons).....
1
3345
by: ppatel | last post by:
Problem I have a problem with web image button control click event. The click event does not get trigger until it has not been clicked once or page refresh occures(which is fine). When click event fires first time it executes code associate with click event(As I expected). the problem is when you refresh page it fires a click event...
9
7719
by: PK9 | last post by:
I'm having an issue with the "Refresh" of an asp.net page. The refresh is actually calling my last onClick event. I thought that asp.net was supposed to be stateless in that it shouldn't remember that I clicked a button before the refresh. Here is what is going on: 1) Page Loads 2) User enters some values, clicks the "Save" button 3)...
3
10015
by: Sameer | last post by:
I have a webpage that has a link button. This link button on click opens up a new page. This is what is happening: 1. Load the web page. 2. Click on the link. 3. Refresh the web-page. Result: The webpage gets refreshed and the link buttons onClick event is fired.
4
3492
by: puja patel | last post by:
hi all, I am developing a shopping cart website in C# where after selecting item, user enters credit card details and click on submit button.This request is then processed by the gateway which usually takes from 5-10 sec of waiting period to get response back if the transaction was approved of declined. I want to implement page which says...
3
1803
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hi all, i betcha here's a question never asked before ;) i have a simple web form with a gridview and a button. the button doesn't do anything but a postback. i load up the gridview from the database, hit the button, then hit the refresh button and here's where my question occurs. I get a message saying that "it needs to resubmit/resend the...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5969
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.