Technical Discussion
  >> Web Design / HTML / Web hosting Forum


Register (or login) on our website and you will not see this ad.


These posts have been archived and can no longer be replied to or modified.
  Print Thread
Standard User cheshire_man
(committed) Sat 10-Oct-09 19:16:14
Print Post

HTML 'goto' required - but #bookmark doesn't do it


[link to this post]
 
Is anyone able to help me what I'm sure must a simple problem on a web site I'm doing.

Each page is invoked via
<a href="index.php?view=page1&amp;ab=zz">Link1 to page1</a>
index.php assembles a filename based on the view and ab parameters yielding something like

/pages/page1.php

Using the PHP Require function it loads a header file, then the page body file, then a footer file.

In some situations I want to be able to go to a page, either from a menu or via a link in, say, page1, but I want to be able to go to somewhere other than the start of the page.

So for example, I may have a drop down menu with the first line going to page1 at the top, the 2nd line goes to page1#section2, 3rd line to page1#section3, and so on.

If I was giving the URL in an anchor I'd put something like
http://www.aaa.ooo.uk/pages/page1.php#section1
I can't seem to be able to do this in the structure I'm using. Thus, in the menu I've tried lines like the following
<a href="index.php?view=page1&amp;ab=zz">When?</a>
<a href="index.php?view=page1&amp;ab=zz&amp;loc=when">When?</a>
<a href="index.php#when?view=page1&amp;ab=zz">When?</a>
The first above works, and goes to top of page
The second works, goes to top of page, and PHP at the start of the page can see the loc param and, ideally, if I could "goto loc" in the PHP, or generate HTML that would do so, problem solved.
The third goes to the index (home) page.

A PHP generated GOTO equivalent wink at the beginning of the loaded page would solve it. Using # bookmarks I can generate an anchor that when clicked goes to the appropriate section, but I need it automatic.

Any suggestions as to how I can achieve this?

Tony
Standard User cheshire_man
(committed) Sat 10-Oct-09 21:29:05
Print Post

Re: HTML 'goto' required - but #bookmark doesn't do it


[re: cheshire_man] [link to this post]
 
To my amazement I've solved it.
<a href="index.php?view=page1&amp;ab=zz#when">When?</a>
worked.

In other words just adding #bookmark name to the two-param href worked. I hadn't though of trying that before. And still not really sure why it works. But it does smile

Tony
Standard User Sandgrounder
(knowledge is power) Sun 11-Oct-09 00:19:31
Print Post

Re: HTML 'goto' required - but #bookmark doesn't do it


[re: cheshire_man] [link to this post]
 
You are quite right - it does work. The anchor works regardless of the presence of query strings..

It works on this site as well - follow this link to see it in use.

This Post Edited to make the point a little more obvious.




























Sorry about all the white space needed here to demonstrate the point. smile



Line One:- Zen - DrayTek Vigor 2600VG
Line Two:- EntaNet - DrayTek Vigor 2600

Edited by Sandgrounder (Sun 11-Oct-09 00:23:25)


Register (or login) on our website and you will not see this ad.

Standard User Etchy
(committed) Sun 11-Oct-09 02:43:02
Print Post

Re: HTML 'goto' required - but #bookmark doesn't do it


[re: cheshire_man] [link to this post]
 
The reason that way works is because thats the way round it was designed to work.

URLs have to conform to a standard or nobody would know how to interperate them.

Have a look at this link for the URI scheme
http://en.wikipedia.org/wiki/Uniform_Resource_Locator
Standard User cheshire_man
(committed) Sun 11-Oct-09 08:36:38
Print Post

Re: HTML 'goto' required - but #bookmark doesn't do it


[re: cheshire_man] [link to this post]
 
Thanks for your replies.

I believe the reason it works is that the # is a reserved character which would require 'escaping' before being used in variables. Thus the un-escaped # and following characters don't get passed to server-side processes (PHP, ASP, Java, etc.).

I'd assumed that the # and following would be passed to server-side PHP and upset the variables or processing there.

Whatever, it's now working, and I've learned something new.

Tony
Standard User walkermore
(newbie) Sat 27-Mar-10 09:26:46
Print Post

Re: HTML 'goto' required - but #bookmark doesn't do it


[re: cheshire_man] [link to this post]
 
sounds good to me

smith
  Print Thread

Jump to