Solved

Link to half way down a web page.

Posted on 2014-01-29
7
494 Views
Last Modified: 2014-01-29
Hi Experts,

I have a web page called mypage.aspx that will contain links to itself in the form:

<a href="mypage.aspx?country=England>Link</a>
<a href="mypage.aspx?country=Scotland>Link</a>
<a href="mypage.aspx?country=Wales>Link</a>

These links will be at different places on the web page.

What I want is that when a link is clicked the page loads from the position of the link that was clicked. So the user does not have to scroll down to find the link they just clicked.
0
Comment
Question by:DColin
  • 4
  • 2
7 Comments
 
LVL 4

Expert Comment

by:Jack Leach
ID: 39819463
Put a link with an octothorpe and the div id.

<a href="#thisplace">jump here</a>
...
...
<element id="thisplace" />

Open in new window


Hth
0
 

Author Comment

by:DColin
ID: 39819477
Where would my "mypage.aspx?country=England" link go.
0
 
LVL 4

Expert Comment

by:Jack Leach
ID: 39819483
The ?key=value indicates a query string, which is generally interpreted by your script to take particular action (for example, loading "England" type data from a database).

What you need is something different, and it's pure HTML.

Instead of:

<a href="mypage.aspx?country=England>Link

Open in new window


use this:

<a href="mypage.aspx#England">Link

Open in new window


Then, as long as you have some HTML element with an ID of "England", the page will jump/autoscroll so that element is at the top.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:DColin
ID: 39819493
The '?country=England' part of the link is an argument that is required by the page asp code. This can not be altered. I need some way of jumping to the point in the page from where the link was clicked.
0
 
LVL 4

Expert Comment

by:Jack Leach
ID: 39819503
Is the ASP code processing that URL/querystring and outputting HTML from it?  If so, you'll need to modify the HTML output to include your internal links and anchors accordingly.

If you need this functionality to be available from an external link, you will have to write the ASP logic to interpret the querystring passed to it and adapt your outputted HTML accordingly.

Again, this anchor jumping is pure HTML, not part of any scripting language, so whatever HTML output you're getting from the request, include the #anchorname links in that.

It's hard to say more without seeing more detail on what's going on.

Hope that helps...
-jack
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39819510
You just need to add the named anchor at the end of your link:

<a href="mypage.aspx?country=England#England>Link</a>

<div id="England">.
0
 
LVL 4

Expert Comment

by:Jack Leach
ID: 39819514
Ah, sorry, I didn't realize you could slap an anchor to the end of a query string, hadn't done it before.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now