473,408 Members | 1,744 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,408 software developers and data experts.

Question about anchors

DogBot
11
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 1864
RamananKalirajan
608 512MB
Try This

I think this is what you are looking for.

Thanks and Regards
Ramanan Kalirajan
Dec 15 '09 #2
DogBot
11
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 Expert Mod 8TB
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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
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
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...

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.