473,756 Members | 3,663 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">cli ck 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.getEle mentById('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 2058
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">cli ck 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.getEle mentById('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().rep lace(/\#.*/,'') + '#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().rep lace(/\#.*/,'') + '#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
1713
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
7283
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 the reference file doesn't like this. link() produces 1) a hard link and b) gives me the following error: OSError: Operation not supported I guess what I'm looking for is a way to call the Unix ln command from
383
12210
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 poor man's DBMS, a broken email server and various other /application/ servers to try and crack the Internet and IS markets. In the case where they didn't spend their own money to get companies to
6
3540
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. The culprits are 2 wide columns which contain e-mail addresses. I can get the page to fit entirely on the printer output if the browser would break the e-mail address string at the '@' symbol. What I've done for now is replaced the '@' in all...
1
3347
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. ... www.soft30.com/download-1-11975.htm - 31k - Cached - Similar pages MDBSecure 1.0.8.0 - Soft30.com Utility which makes it easy to create secure MS Access Databases, ... MS Access 2000/2003 format. 30 day money back guarantee, 30 day trial. ...
4
4058
by: vasu1308 | last post by:
Hi I want to about Soft link and Hard Link in Linux. Thanks Vasu
0
1150
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 BON MARCHE (ALL CARDS ACCEPTED) http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia +
0
1577
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 generique +++ Cholestérol +++ Cholestérol +++ Cholestérol +++ + http://jhku.net/ACHETER-LIPITOR-BON-MARCHE/ http://jhku.net/ACHETER-LIPITOR-BON-MARCHE/ ACHETER LIPITOR BON MARCHE (Western Union, Diners, AMEX)
0
1361
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 +++ PERTE DE POIDS +++ PERTE DE POIDS +++ PERTE DE POIDS +++ + ACHETER DU ACOMPLIA BON MARCHE (ALL CARDS ACCEPTED) http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia http://groups.google.com/group/acheter-du-acomplia-acheter-acomplia...
0
9456
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
9273
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10032
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
9872
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...
1
9841
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9711
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
6534
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
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.