Solved

anchor doesn't preserve my URL

Posted on 2011-03-09
15
681 Views
Last Modified: 2012-05-11
The url to my page looks something like:
http://localhost/portal/demo/index.cfm?label=Pittsburg&page_id=30

I have an anchor on my page that looks something like:
<a href="#gohere">

When I click on the anchor I would like it to go to:
http://localhost/portal/demo/index.cfm?label=Pittsburg&page_id=30#gohere

But instead it tries to go to:
http://localhost/portal/demo/#gohere
which causes an error.

How do I create an anchor that preserves the URL parameters?

Thanks for the help
0
Comment
Question by:WestCoast_BC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +2
15 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 35091549
I can't reproduce your problem.  I tried it in both IE and Firefox, and for me, the CGI parameters are always included in the URL when I go to an anchor, just like you want.

Do you have some .htaccess action going on, rewriting the URLs?
0
 

Author Comment

by:WestCoast_BC
ID: 35092374
Here is a sample link that is not working:

http://www.adreflex.com/sandbox/adreflex/index.cfm?page_id=26&menu_id=67&Label=test%20page

I have not created a .htaccess and I am not aware of any URLs being rewritten.  Could this something that my ISP might be doing and might be able to solve?

Thanks again for the help.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35092553
That link leads to your test page.  What is it not doing?
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:WestCoast_BC
ID: 35092614
Try clicking on the link on the page.  When you click on the link I want the URL to be:
http://www.adreflex.com/sandbox/adreflex/index.cfm?page_id=26&menu_id=67&Label=test%20page#Anna 

but instead I get:

http://www.adreflex.com/sandbox/adreflex/#anna 
0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 35092660
Are you resolving your URL  also so as to make them User friendly as i see in your tst link!

if you link is inside the cfoutput, then you should provide a ## around it as i se there is no such cause, neither you are getting any Error!

Exact Syntax for a Tag type of Anchor is:

<a href="#C4">

and then below it should be:

<a name="C4">Chapter 4</a>

as you do need to specify the full path

are u using fusebox i thing 'Yes'
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35092752
This is what is in your page.  Since there is no query string there, there is nothing to preserve.  It's doing exactly what it should be doing.
<p>here is my test link <a href="#anna">page</a></p>

Open in new window

0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35092808
Ok, I read the question again.  The page address is everything before the question mark and the query string is everything after it.  The anchors you are creating are incapable of carrying the query string without it expressly being added to the anchor.  The query string part is not automatically preserved.
0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 35093015
@ dave

There is no need to pass the query String with it! as it will render automatically!
0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 500 total points
ID: 35093232
You have a base href tag on the page that is overriding its actual URL.

Get rid of this first line in your and the link will be better:

<base href="http://www.adreflex.com/sandbox/adreflex/"> 

Open in new window

0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 35094249
Good catch @sj
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35097601
I don't (yet) know about it "render automatically" but I was thinking of relative links for some reason instead of named anchors.  Duh.
0
 
LVL 1

Expert Comment

by:witsCOMPUTING
ID: 35098003
Try this...

<a href="index.cfm?#cgi.query_string###gohere">
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 35098041
Did you get rid of your base-href tag?  Nothing will work right until you do!
0
 

Author Comment

by:WestCoast_BC
ID: 35098347
Thanks for all of the input.  I will try and remove the base href code tonight and let you know if that solves my problem.  

Unfortunately witsCOMPUTING suggestion to do something like:
<a href="index.cfm?#cgi.query_string###gohere">

won't work for me easily.  The text is created via CKEditor and I would have to change CKEditor and update its anchor code in the source.
0
 

Author Comment

by:WestCoast_BC
ID: 35109499
Getting rid of the <base href="... line solved my problem.  Unfortunately I now have a different problem.  I set a bunch of styles dynamically and now when I get rid of the<base href line my styles don't work properly.  Very puzzling.  I know my style .cfm page is being included because I put some test code in it and the test code is being executed.

I will post the solution when I figure out what is going on.
0

Featured Post

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

724 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