473,769 Members | 6,286 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reloading a page before to follow a link

Hello all,

I've a very simple problem that appears to don't have a simple
solution.
I've a (dynamically generated) page with a number of external links.
What I need is that if the user clicks on an external link, before
to reach the link, the current page gets reloaded.

My first try was the obvious:

window.location .reload();
window.location ='...';

This works in Firefox but does not on IE.
My second try what something like:

window.onload=f unction() {window.locatio n='...';};
window.location .reload();

but this does not work in Firefox nor IE, other browsers not tested.
How can I fix this?

It is just as fine if there is a way to reload the page after the user
press the BACK button of the browser.

But I want to spend some word about why I've this problem, maybe
I'm doing something wrong.

Well that's simple, if I change stuff in the page using Ajax, when
the user follow a link, and then go back with the BACK button of
the browser the page does not "remember" that it was updated
via Ajax.

Thank you very much for any help,

p.s. what still I didn't tried is to put the reload as body.onLoad
event
and use cookies to set a flag so that at the first load it will not be
reloaded (forever... in a loop), but when I leave the page I set
the cookie before to leave, then when I'm back the reload will happen,
deleting the cookie just before to reload. Is this an idiomatic
solution?
I may like more one without a cookie if possible.

Regards,
Salvatore

Feb 22 '06 #1
8 2072
Hi Salvatore,

Seems like you are complicating things urself..
Call the below reload() function whereever required. To demonstrate
you, I have just called it in the OnUnload event..

Hope that this is what you have been working for :)

Chaitu..

<html>
<head>
<title>Wanna leave my site?? Huh!! No way</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<SCRIPT language="javas cript">
function reload()
{
location = location=self.l ocation
}
</SCRIPT>
</head>

<body bgcolor="#FFFFF F" text="#000000" onUnload="reloa d()">
<a href="http://www.google.com" >click</a>
</body>
</html>

Feb 22 '06 #2
Salvatore Sanfilippo wrote:
I've a very simple problem that appears to don't have a simple
solution. I've a (dynamically generated) page with a number of
external links. What I need is that if the user clicks on an external
link, before to reach the link, the current page gets reloaded.


This is not at all possible (or reasonable). Given that an event is
retained from one execution context to the other, after the first one
was exited, which it should not, one scroll motion and your entire
concept blows up.
PointedEars
Feb 22 '06 #3
ch***********@g mail.com wrote:
<html>
<head>
<title>Wanna leave my site?? Huh!! No way</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<SCRIPT language="javas cript"> ^^^^^^^^^^^^^^^ ^^^^^^^ function reload()
{
location = location=self.l ocation ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^ }
</SCRIPT>
</head>

<body bgcolor="#FFFFF F" text="#000000" onUnload="reloa d()"> ^^^^^^^^^^^^^^^ ^^^^ <a href="http://www.google.com" >click</a>
</body>
</html>


It has been a while since I have read such utter nonsense here.
PointedEars
Feb 22 '06 #4
Hi Thomas,

He says its a dynamically generated page right!! Why can he not
assosiate the reload() function with OnClick event of the external
links at design time??

Just to know why you call my code nonsense.. :)

Thanks, Chaitu..

Feb 22 '06 #5
ch***********@g mail.com wrote:
Hi Thomas,
Hello. Please quote the minimum of what you are replying to
and provide attribution of quoted material:

<http://jibbering.com/faq/faq_notes/pots1.html#ps1P ost>
<http://safalra.com/special/googlegroupsrep ly/>
He says its a dynamically generated page right!!
That does not matter here. The HTTP client does not care about
it, even if it knew about it. So does the user agent and the
client-side script engine.
Why can he not assosiate the reload() function with OnClick
event of the external links at design time??
The code posted is not executed at design time at all, therefore
the event listener is not assigned at design time.
Just to know why you call my code nonsense.. :)


Google for language="javas cript". About the rest of your code:

| location = location=self.l ocation

Those three expressions all refer to the same object and value. It is as
if you would assign x = x = x.

With the important difference that once something is assigned to the
`location' property of the Global Object (there is an implicit property
access here, through the scope chain), all the code that triggered it is
usually gone, as the execution context is associated with that Global
Object.

If it is not gone (which would be relying on unspecified _and_
undeterministic behavior), this would reload the document twice.
_With_ using the cache, so it would change (almost) nothing.
PointedEars
Feb 22 '06 #6
Sorry people,

The js function was intended to be :

function reload()
{
location =self.location
}

But this works with page onUnload event.
He said :

window.location .reload();
window.location ='...'; works with Firefox but not with FF. the above
works with Firefox as well.

If in case some one wants to use it with page unLoad event whatever be
the link.. it doesnt allow..

Thanks for your replies Thomas..

Regards, Chaitu

Feb 22 '06 #7
Salvatore Sanfilippo wrote:
My first try was the obvious:
window.location .reload();
window.location ='...';
This looks crazy ;]

You can reload by adding a url into the query string, something like:

window.location = 'url?redirectTo =' + newURL;

And after reloading you can check this variable and redirect if it's setted.
Well that's simple, if I change stuff in the page using Ajax, when
the user follow a link, and then go back with the BACK button of
the browser the page does not "remember" that it was updated
via Ajax.


This so-called "AJAX" is bad, you can see more mistakes here:
<URL:http://alexbosworth.ba ckpackit.com/pub/67688>, but it's quite cool.

To solve your problem you can avoid caching, so the page will always be
reloaded. You also can check through the XMLHttpRequest if something
changed too and get the new stuffs, etc. But the solution that you
choosed above is really strange hehe ;]
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Feb 22 '06 #8
ch***********@g mail.com wrote:
Sorry people,
No. Your further disregarding of posting guidelines is not excused.
The js function was intended to be :

function reload()
{
location =self.location
}
Which is still not reasonable, as it uses the cache.
But this works with page onUnload event.
For appropriate values of "works".
He said :

window.location .reload();
window.location ='...'; works with Firefox but not with FF.
Pardon?
the above works with Firefox as well.
If it does, which is yet to be showed, that does not make it reasonable.
If in case some one wants to use it with page unLoad event whatever be
the link.. it doesnt allow..


In English, please.
PointedEars
Feb 23 '06 #9

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

Similar topics

4
8180
by: Greg Bryant | last post by:
Wondering why my setcookies didn't have any impact, I noticed the line in the manual that said the page needs to be reloaded before they take effect (which does make a certain kind of sense). So, how do I force a page to reload? Thanks, Greg
4
2773
by: J. J. Cale | last post by:
Hi Obviously I'm new to PHP. I would like to be able to update a table in a page from a database on the server without reloading the page each time. Is this possible with PHP? TIA Jimbo
8
4014
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated answer. The problem is this: when the user presses the Calculate button, the whole page is reloaded and, on a large page, this is very noticeable. Is there any way that I can get the calculation done and the result displayed without reloading...
2
5100
by: Snolly | last post by:
Hi all, Here is my issue. I have a web page (lets call it page1) with an iframe in it that then opens a pop-up window (page2). The pop-up window is used to edit some data that was loaded into page1 so I want to use onunload to reload page1 to keep the data synchronized. At first I was using just window.opener.parent.location = window.opener.parent.location;
1
1441
by: Dynamo | last post by:
Hi My site uses frames and some of the frame pages are ranked higher in search engine rankings than the main page. When somebody clicks on the link it takes them to the frame page and they don't see my page as it should be viewed plus it displays a javascript error. I need a way using javascript so that when the link is clicked on in either yahoo or lycos that it loads the main frame html page (not the subframe html) and that the...
6
3986
by: iwearwatches | last post by:
Group, What a root canal. Here is what I have: I have a page that has several layers that I will either show/hide based on a graphic/tab that the user clicks. (works perfectly)
3
2156
by: Richard | last post by:
Hey there, I have a textbox and a listbox. When a user types a number in the textbox, I want to get all the records from a MS Access DB but without reloading the page. I now have something manual and a user first must press a button to get the listbox filled with records but I want to have it done automaticly without pressing a sumbit button. I know its prolly done with javascript but thats one thing
1
1359
by: Dave Moore | last post by:
Hi All, Here's my problem. I'm having trouble managing the additional variables on the end of my URL. For example, I might have a URL like the following: http://www.mydomain.com/index.php&option1=5&option2=7 It's the 'option' variables I'm having problems with. I would typically use variables of this form to control various aspects of the current page. However, the actual options present will be dependant on the current mode of the...
7
14015
by: TomDestry | last post by:
I have a web page and lots of XML files. When a link is clicked on the page, it calls a function via onclick with the XML file as a parameter: <body onload="InitContent();"> <a name="fileName" class="blah" href="javascript: void(0)" onclick="OpenColumnInfo('fileName')">Whatever</a> </body> OpenColumnInfo() takes the filename and reads in the relevant XML then squirts the contents into various tags on the current page, so there is no...
0
9587
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3958
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
3
2815
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.