Connecting Tech Pros Worldwide Help | Site Map

updating URL and passing URL info with frames and js...

Newbie
 
Join Date: Jan 2007
Posts: 2
#1: Jan 23 '07
Ok, Here is my situation... we have a 64 page pdf that we have broken up into separate pages. We are needing a frame set to have a "Previous Page and Next Page" navigation at the bottom of the window. I am wanting to capture the URL in the top frame where the PDFs are displayed and update the URL of the URL/pdf to be +1 or -1. Example of top frame URL: www.MySite.com/pdf/page01.pdf so now the bottom frame needs to read the URL and see "page01.pdf" add one (+1) to the 01 to make it 02 (page02.pdf). I understand that once at 01 that you can't go to 00 or that at page 64 we cannot goto 65, we are only offering 64 pages. But right now, I can't seem to get the URL to pass, read, and updated to be the next or previous page.

I have searched and tried too get some hints, tips or tricks but mostly coming across passing Queries after the URL... which is interesting read, but not assisting with my issue at hand. So in a nutshell, HELPPPPP!!! please?

<header>
function showDef(t) {
top.Frame1.activeDef = top.Frame1.location.href.window.frameElement("page " + t);

<in the body>
<a href="#" onclick="showDef(+1)">Next


I know that we can back up on the URL, but am I heading in the wrong direction with this or what?

Regards,
Charles
Newbie
 
Join Date: Jan 2007
Posts: 2
#2: Jan 23 '07

re: updating URL and passing URL info with frames and js...


Ok, I just found this http://javascript.about.com/library/blurl2.htm which provided a method for getting the information but now I am doing it with frames and still need to add or minus...
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#3: Jan 24 '07

re: updating URL and passing URL info with frames and js...


Assuming you have figured out how to obtain the url and the file name, e.g. page01.pdf, there are a number of ways to search the string to gain what you need.

You could use regular expressions to get the current page number (01) or
search the string for page and the .pdf and get the value in between. For this, you can use string methods such as indexOf, match, substr, etc. See here.

You are passing +1 when in fact you should be passing just 1. In your function, parse the 01, 02, etc. current page value using parseInt(). Then add 1 or whichever number you have passed. Obviously, if you reach 64, the next button/link should not even be available. Now to maintain the leading zero, just include the following:
Expand|Select|Wrap|Line Numbers
  1. if (pageno < 10) t = '0'+pageno;
Hope that helps.
Reply