473,503 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

follow a link ('soft')

Hi everyone,

I have this nasty little problem to which I can't find a solution:

Consider an anchor <a name="Top" id="Top">Top</a>

How can I follow/execute this link from within javascript? In other words, how can I mimic the action that occurs when a user has clicked a (non-existing) <a href="#Top">click me</a> link, so that the page will be shifted to the top (that's an example - not the actual goal)

The link must be followed in the 'softest' possible manner: no opening of new window or page reloads/refreshes.

something like: document.getElementById('Top').follow()

Any help is greatly appreciated.
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
"Quot capita, tot sententiae" - Terentius , Phormio 454
Jul 23 '05 #1
2 2043
Joris Gillis wrote:
Hi everyone,

I have this nasty little problem to which I can't find a solution:

Consider an anchor <a name="Top" id="Top">Top</a>

How can I follow/execute this link from within javascript? In other
words, how can I mimic the action that occurs when a user has clicked a
(non-existing) <a href="#Top">click me</a> link, so that the page will
be shifted to the top (that's an example - not the actual goal)

The link must be followed in the 'softest' possible manner: no opening
of new window or page reloads/refreshes.

something like: document.getElementById('Top').follow()
The following script modifies the window.location to go to a
specified anchor. The anchor does not have to be visible, it just
has to exist.

Note that you can't simply append the new anchor to the current URL,
so the script removes any pattern matching #.* in the string of
window.location, then adds the new anchor. This is a bit simplistic,
you may need a more robust solution.

I've wrapped lines to prevent autowrapping so the onclick looks a bit
strange.
<a href="#pageFoot" name="pageTop">Normal anchor - go to foot</a>
<br>
<input type="button" value="JS function - go to foot" onclick="
window.location =
window.location.toString().replace(/\#.*/,'') + '#pageFoot';
">
<br>
<div style="position:absolute; top:2000px; border:1px solid blue;">
<input type="button" value="JS function - go to top" onclick="
window.location =
window.location.toString().replace(/\#.*/,'') + '#pageTop';
">
<br>
<a name="pageFoot" href="#pageTop">Normal anchor - to to top</a>
</div>


Any help is greatly appreciated.

--
Rob
Jul 23 '05 #2


Joris Gillis wrote:
I have this nasty little problem to which I can't find a solution:

Consider an anchor <a name="Top" id="Top">Top</a>

How can I follow/execute this link from within javascript?


It is an anchor not a link but you can move to an anchor with
window.location.hash = '#Top';

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3

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

Similar topics

0
1692
by: Christian Seberino | last post by:
how do a post-install command like create a soft link? ..or where add command to setup.py?? I want to create a soft link automagically when user installs this program. Chris
2
7261
by: Markus | last post by:
Hello, I'm running on Mac OS X and need to create a soft link to a file. I tried both makealias() and link(). While makealias creates a Finder alias just fine my application that needs to read...
383
11782
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
6
3530
by: Mark | last post by:
Hi, My page has a table with many columns such that the right-side of the table gets chopped off when printed. I specify a table width of 100%, but otherwise no cell dimensions are specified. ...
1
3307
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ......
4
4043
by: vasu1308 | last post by:
Hi I want to about Soft link and Hard Link in Linux. Thanks Vasu
0
1137
by: paulvz882 | last post by:
comprimes de acomplia en France commander acomplia en ligne aucune prescription acomplia canada soft en ligne +++ PERTE DE POIDS +++ PERTE DE POIDS +++ PERTE DE POIDS +++ + ACHETER DU ACOMPLIA...
0
1564
by: hessman1234 | last post by:
achat lipitor canada bon marche achat lipitor au rabais en ligne sans prescription acheter lipitor le plus bon marche un Achat de achat lipitor us usa avec livraison achat lipitor belgique soft...
0
1350
by: jkjtjktjktjhktjk | last post by:
acheter du acomplia cinq acomplia par email PERTE DE POIDS en France acomplia canada soft en ligne acomplia belgique acomplia belgique bon marche acheter du acomplia en ligne sur internet +++...
0
7205
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,...
0
7093
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...
0
7348
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...
1
7006
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
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...
1
5021
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...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1519
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 ...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.