Solved

Deep Link into HTML page

Posted on 2006-07-21
28
249 Views
Last Modified: 2010-04-17
I need to find a way to link to a specific part of an html page.  I subscribe to a service that provides HTML docs to my company.  When I pull up the HTML page there can be one or multiple documents all on the same HTML page.  For example, one HTML page that I just looked at had 12 separate documents within that one HTML page.  What I want to do is come up with a way that I can have a hyperlink open the HTML page to the specific part of the page that each document begins at.  For example, the HTML page that I just looked at has these documents:

AIM Basic Value Fund
AIM Conservative Allocation Fund
AIM Global Equity Fund

I want to create a hyperlink for each of the three documents above, but when I click on the hyperlink for AIM Basic Value Fund I want the HTML page to open directly to the first page of the AIM Basic Value Fund document.  When I click on the link for the AIM Conservative Allocation Fund I want the HTML page to open directly to the first page of the AIM Conservatie Allocation Fund document.  I want the same thing for the AIM Global Equity Fund and for the other 8 documents that are part of this HTML page.

I don't have any control over that HTML page that is created and provided to me.  Is there any way to do what I want?  Or is it impossible?
0
Comment
Question by:scottspivey
  • 15
  • 11
  • 2
28 Comments
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
If I understand you correctly...


Right before the header for each document, add something like this:

  <a name="DocReference"></a>

Then, to jump to this part in the web page, you create a link like this:

  <a href="#DocReference">Jump to some part of this page</a>


Obviously, you need to change the value from 'DocReference' to a relevent title which must be different for each header.


Is that clear?
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
InteractiveMind,

that is clear and would work if i had any control over the source code for the pages that i am accessing.  here is part of the code for one of the pages that i need to go directly to:


YOUR GOALS. OUR SOLUTIONS.   [AIM INVESTMENTS LOGO APPEARS HERE]
<BR>
--Registered Trademark--          --Registered Trademark--
</SPAN>
</P>
<HR CLASS="eolPageBreak">
<A NAME="eolPage34"></A>
<P CLASS="eolCenter eolNewPage">
<SPAN STYLE="font-weight: bold">
AIM CONSERVATIVE ALLOCATION FUND
<BR>
PROSPECTUS
<BR>
</SPAN>
APRIL 24, 2006
</P>
<P>
AIM Conservative Allocation Fund seeks total return consistent with a lower
level of risk relative to the broad stock market.


the only thing i know about this page, without viewing the source code, is the name of the fund is AIM Conservative Allocation Fund.  is there anyway to link to that name without having an anchor at that spot?
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
the anchor "eolPage34" doesn't do me any good because i don't know what it is without looking at the code.
0
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
That's not the first time I've overlooked parts of a question and posted a useless comment today.
Am really sorry.


I will give it a proper read, and see what I can come up with.
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
that is fine.  thanks for trying to help.
0
 
LVL 7

Expert Comment

by:yotamsher
Comment Utility
is modifying the HTMLs with a script an option?
0
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
scottspivey, does your server support PHP?
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
yotamsher,

possibly.  i would have to look at the company i get the html from to be sure we aren't infringing on anything.
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
InteractiveMind,

i don't currently run PHP.  i will have to get with my developers to see if the server supports it.  is there somthing i can look at to know?  i run windows server 2003 standard if that tells you anything.
0
 
LVL 7

Expert Comment

by:yotamsher
Comment Utility
in case you can modify the htmls, you will be able to add anchors in the places you wish to point, and then offcourse you can point it with the # in the URL
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
InteractiveMind,

i just verified that my server does support PHP and they DLL is already installed.
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
yotamsher,

that will work as long as i have access to modify the html.  even if i can just add an anchor that would allow me to do what i need.
0
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
Okay, that's good -- perhaps we can create a PHP solution.

Keeping in mind that I despise web development, I shall try and get something working for you. ;-P


By the way, do you know off your head which version of PHP is installed?
If not, then not to worry..
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
no idea, but i will find out.  i need to know anyway.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 25

Accepted Solution

by:
InteractiveMind earned 500 total points
Comment Utility
Okay, give this PHP code a go:


<?php

$url = $_GET['url'] ;

if ( isset( $url ) )
{
   
   // The URL has been specified, so process it here
   
   $html = file_get_contents( $url ) ;
   
   echo stri_replace( "AIM CONSERVATIVE ALLOCATION FUND", "<a name=\"ee2006\"></a>AIM CONSERVATIVE ALLOCATION FUND", $html ) ;
   
} else
{
   
   // The URL has not been specified, so retrieve it here
   
   echo "<form action=\"" . $_SERVER['PHP_SELF'] . "#ee2006\" type=\"GET\">" ;
   echo    "<input type=\"text\" name=\"url\">" ;
   echo    "<input type=\"submit\">" ;
   echo "</form>" ;
   
}

function stri_replace($search,$replace,$text)
{
   if (!is_array($search))
   {
      $search = array($search);
      $replace = array($replace);
   }
   foreach($search AS $key => $val)
   {
      $search["$key"]  = '/'.quotemeta($val).'/i';
   }
   return preg_replace($search,$replace,$text);
}

?>



And that should do it.

It seems to work for my setup.


If you need any help setting it up, or using it etc, then just let me know...
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
InteractiveMind,

i don't know anything about PHP so you will have to walk me through the setup and use.
0
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
Okay, no probs...


- Open a text editor (such as Notepad), and copy and paste the above code into it;

- Save this file somewhere convenient (such as your desktop) with an appropriate filename, but it must
  end with a .php extension ("DeepLink.php" for example);

- Now you need to move/upload this PHP file onto your web server... are you able to do this?


Once the PHP file is on the web server, it's ready for use.

So if for example, you saved the file as "DeepLink.php" into the root of your web server, then you can access it in your browser with the following URL:

http://yourWebServersName/DeepLink.php



If it all works okay, then there will be a text field, and a submit button next to it.

Simply copy/paste the URL of one of the HTML pages into that text field, and hit the submit button... and it will hopefully do what you require.


[This PHP code can of course be customized so that you can interact with it differently. But let's see if this works fine first..]
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
ok that makes sense.  i am going to test this over the weekend and see how it works.  one prob though, i was trying to find out my version of PHP and the solution I found does not work.  I found a post to write a php file:

<?
        phpinfo();
?>

i saved that file into my http folder where all my other code is at and when i try to run it i get a page cannot be found error.  my hosting company tells me PHP is installed.  do i need to activate it or set it to run as a service?
0
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
Well,

<?php
        phpinfo();
?>

is generally more compatible.


But if you're getting a "page cannot be found" error, then it would seem to be independent of your PHP setup.

Are you sure that you're typing the correct filename?

Also, be careful that when you saved your PHP file with it's .php extension, that your text editor didn't append a .txt or anything to it... So, filename.php.txt is NOT what you want; it must be filename.php..



(BTW, typically when 'they' say "PHP is installed", that means it's all setup and ready to go)
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
that is what i thought.  i am double checking now to be sure i have spelled everything correctly.  i will rewrite the php like you suggest and see what happens.  if that still doesn't work i will give a call to support and see what is going on.  i will post back as soon as i find out something.
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
still couldn't get the test.php file to work.  i have tech support working on this now and my wife is telling me that i am taking her out to eat dinner, so i may have to drop this for now and pick it back up over the weekend.

alas my tech support is now telling me that php is not installed.  i love it when i get two answers to the same question.

i will have to install that over the weekend.  is there a specific source that i need to get the php from?  and is there a particular that i need to get?

i will get everything and install it over the weekend so i can run your script and see what happens.

thx.
0
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
hahaha that's a pain.


To install PHP:

You can get the official installation from here:
http://www.php.net/downloads.php

But configuring PHP can be a bit of a pain, so I personally use WAMP:
http://www.wampserver.com/en/

WAMP basically installs and configures PHP (and if you want, MySQL etc) all for you.
It couldn't be easier (wellll....).

Once installed, I imagine that you will need to reboot your Windows Server for it to work; is this possible?


Well, have fun.

I'm in the GMT timezone, so will be disappearing for several hours soon-ish.

However, I will be on most of this weekend, so will help you then if necessary..
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
does Perl have anything to do with PHP?
0
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
Well, sort of....

- PHP and Perl are both Programming languages;
- PHP is a web-based [server side] language; and Perl can (and quite often is) also used for similar purposes;
- The Perl language had quite an influence on the PHP language (such as syntax etc);
- Perl and PHP (among others) can be integrated together fairly easily;

But they're both independent.
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
ok thx.  i will get php running and let you know how the script works out.  i have sent a copy to my developers also so they can look at it.  if the basic idea works they should be able to customize it to our specific needs.
0
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
No probs.
Have a good night.
0
 
LVL 1

Author Comment

by:scottspivey
Comment Utility
InteractiveMind,

sorry it has taken me so long to get back to you.  i did not have much time to spend with this over the weekend but i did pass it on to my developers and they are going to be able to use what you started and customize it to our specific needs.  thx for the help, you have saved me a ton of time.

scott
0
 
LVL 25

Expert Comment

by:InteractiveMind
Comment Utility
You're welcome  :-)

If any queries to pop out however, feel free to ask..
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

728 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

8 Experts available now in Live!

Get 1:1 Help Now