473,383 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 14375
In article <3f********@news.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="document.location.reload
(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="urlOfCurrentPage.html"
onclick="window.location.reload(true);return false;">Refresh</a>

or

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

--
| Grant Wagner <gw*****@agricoreunited.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.javascript:
<a href="urlOfCurrentPage.html"
onclick="window.location.reload(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="urlOfCurrentPage.html"
onclick="location.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.javascript:
Grant Wagner wrote on 14 jul 2003 in comp.lang.javascript:
<a href="urlOfCurrentPage.html"
onclick="window.location.reload(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="urlOfCurrentPage.html"
onclick="location.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.javascript:
Grant Wagner wrote on 14 jul 2003 in comp.lang.javascript:
<a href="urlOfCurrentPage.html"
onclick="window.location.reload(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="urlOfCurrentPage.html"
onclick="location.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="document.forms[0].submit();">Submit</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*****@agricoreunited.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="document.location.reload
(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
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 ==...
4
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...
6
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...
10
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...
1
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...
9
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...
3
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:...
4
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...
3
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.