473,802 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
+ 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 1888
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
2323
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 problem with reconstructing the target "Location" http header because I'm missing just one thing. My links look as follows: http://www.oldurl.com/beanie.php#three?register=false&demt=43
1
1592
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 have a table with two columns and two rows in it. In the upper left corner, I have a logo image for my company. In the top right column/cell, I have some navigational stuff, no big deal. In the left cell in the 2nd row, I have a list of anchors of...
2
1626
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 searched words are inside <a href> tags, the links are lost after putting my anchors. For example: <a class="Programa" href="#" OnClick="window.open('/something.tif');"
1
2034
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 searched words are inside <a href> tags, the links are lost after putting my anchors. For example: <a class="Programa" href="#" OnClick="window.open('/something.tif');"
2
1888
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 cancel. and if ok is clicked i have to view that link, if cancel, then it should not open that link. How to do this?
21
2480
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
1292
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
2379
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 text</a> . Could be further complicated by the ASP and SQL designation of URL. like: http://sampleURL.org/FAQs.asp?FAQMID=11&NumFaq=10&bmode=Main W3C validator said 91 errors, mostly on tables, fonts and graphics, but didn't seem to complain about...
19
1344
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 up the website. Any help would *greatly* be appreciated!!! Thanks!
3
16563
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 HREFS
0
9699
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
9562
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
10536
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
10304
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
10285
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,...
1
7598
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
6838
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();...
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
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.