473,473 Members | 1,576 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Question about anchors

DogBot
11 New Member
To define my question I need to establish an example:
Let's say I have a web page (MYPAGE.HTML) and
this webpage is constrained in width.
This web page has 200 lines of text.
I have an anchor on line 30
Expand|Select|Wrap|Line Numbers
  1. <a name="myanchor">
and a link on the first line that points to that anchor
Expand|Select|Wrap|Line Numbers
  1. <a href="#myanchor">go to anchor</a>
If I click on the link the webpage will scroll up so that line 30
is now at the top of the browser window.

Here is the question.
I do not want line 30 to come to the top of the browser. I want it to come up to
the middle of the browser page (or any other point lower that the top of the page)
Say for example 50 pixels from the top.

I cannot do it by moving the anchor point to another line or adding another anchor point. I must do it using CSS or Javascript or both.

Don't be concerned about why, please, it will just complicate the question.My biggest problem so far has been explaining the problem!
But if you must know see this thread

Thanks
Dec 15 '09 #1
3 1866
RamananKalirajan
608 Contributor
Try This

I think this is what you are looking for.

Thanks and Regards
Ramanan Kalirajan
Dec 15 '09 #2
DogBot
11 New Member
Thanks Ramanan, this gives me the basic mechanism for doing this. As far as implementation I suppose I need to somehow dynamically get the current position of all anchors on the page and then programatically change them to that value + 300px(or whatever number I need)

Having said that I have no idea how one does that...but I will start searching the web for the first part (get the current position of all anchors on the page)
and go from there.

Again thanks

P.D. or maybe an "onclik" command? but this would imply inline JavaScript which i do not want to do to my client..I you have any ideas I'd appreciate them. Thanks
Dec 15 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
P.D. or maybe an "onclik" command? but this would imply inline JavaScript which i do not want to do to my client..
then use:
Expand|Select|Wrap|Line Numbers
  1. Element.onclick = fnName;
  2. // or
  3. Element.addEventListener("click", fnName, false); // true if you want to capture the event
Dec 16 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Ben Wilson | last post by:
To anyone who can help me, you have my thanks in advance. I am implementing a "301 Moved Permanently" redirect in my website due to a change of our domain names. Unfortunately, I am having a...
1
by: Frank Wood | last post by:
Hi, I am cross posting this because I'm not really sure which area (HTML/DHTML, Javascript, CSS, etc.) I need to post this question in. I'm also fairly new to all this - please bare with me. I...
2
by: mlv2312 | last post by:
Hi, I have experienced problems when dealing with nested anchors. I implemented some code to perform highlighting and specific anchors are used for the searched words. The problem is when the...
1
by: mlv2312 | last post by:
Hi, I have experienced problems when dealing with nested anchors. I implemented some code to perform highlighting and specific anchors are used for the searched words. The problem is when the...
2
by: learner | last post by:
Hi, A document has many Anchors. I want to take a particular action only if some particular anchors are clicked. I mean if some anchors are clicked, i want an alert box to pop up with ok and...
21
by: adrian suri | last post by:
Hi just started to experement with styleshhets, and have defined hover a:hover { Color : red; Text-decoration : none; Border-top-width : medium; Border-right-width : medium;
5
by: mike | last post by:
i want to use onFocus tag in order to remove dot line but it is very disgusting everytime i wrote this <a> tag so my question is can i use onfocus tag in CSS?? it will be helpful to me... thanks
12
by: Rich | last post by:
Strangely, on-page anchors will work on MSIE, but not on Netscape7.2 or Firefox1.5. All anchors are numbers e.g. <a href="#21">TOPIC</a> supposed to connect down to <a name="#21>beginning of...
19
by: landingone | last post by:
How do I add a link to download a *.pdf file in Dreamweaver? I admit I'm not very savvy with this and usually just do a cut and paste from a *.doc document. I inherited this from someone who set...
3
by: windandwaves | last post by:
does it matter if I write var anchors = document.getElementsByTagName("A"); or var anchors = document.getElementsByTagName("a"); Or is there a better way to catch both <a hrefs and <A...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...
0
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...
0
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
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...
0
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 ...
0
muto222
php
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.