PDA

View Full Version : jump to page section?


Sayian
11-02-2005, 05:36 AM
is their a java script function i can use in the middle of the body ( not head ) that will allow me to jump to a HTML section of a page? Like, on my search page .. after the user searches, id like it to goto the middle of the document b/c thats where the results are displayed.

Thanks for any help.

PhotoJoe47
11-02-2005, 06:12 AM
Do you mean like bookmark of a very long page?

PhotoJoe

Sayian
11-02-2005, 06:13 AM
yes that is what i meant

Id like to jump to a page section, not really a link tho. Just a section of a page.

PhotoJoe47
11-02-2005, 06:38 AM
yes that is what i meant

Id like to jump to a page section, not really a link tho. Just a section of a page.

To go from one page to a section of another page you need to create a bookmark for each place in the to page.

<a name="bookmarkName"></a>

Then on the from page you will need a link to that page
<a herf="completePathToPage.htm#bookmarkName></a>

[edit]

Now you don't have to display the link on the from page but have a variable that you have a function use to goto that page after the search.

[Edit again]

I read your orginal post again. I think you were wanting to do this from the same page, right?

If so, you place the bookmark where you will be displaying your search results. Then as the last step of your search function you use the link as listed above but only use #bookmarkName.

PhotoJoe

vwphillips
11-02-2005, 08:01 AM
you may wish to look at

http://www.vicsjavascripts.org.uk/PageNavigator/PageNavigator.htm

or an extended version on the home page

http://www.vicsjavascripts.org.uk

Sayian
11-03-2005, 04:15 AM
Thank you for your replys, i understand what must be done now.

Im having a problem doing this though, b/c on my search form, when they click search, how could i append #bookmarkname to the end of the query string? ..

Im trying to do this on a search page sending the search information as GET ... And idea how i could tack that on to the end of the URL when they searched? It would be easy to add it as a hidden element in the form, but that wont get it onto the end of the string.

PhotoJoe47
11-03-2005, 06:57 AM
Thank you for your replys, i understand what must be done now.

Im having a problem doing this though, b/c on my search form, when they click search, how could i append #bookmarkname to the end of the query string? ..

Im trying to do this on a search page sending the search information as GET ... And idea how i could tack that on to the end of the URL when they searched? It would be easy to add it as a hidden element in the form, but that wont get it onto the end of the string.
I think I mention this before, but I'm not a javascript expert (yet :D ).

I thought I knew the answer to this off the top of my head but I can't quite seem to get it straight. It might help me to know which event handler you are using to request the search?

PhotoJoe

Sayian
11-03-2005, 07:48 AM
Im not using an event handler to request a search. I just need to goto a certian part of the page when the page is loaded, but i cant place whatever javascript to do this in the head section, it must be in the body.

PhotoJoe47
11-03-2005, 08:05 AM
Im not using an event handler to request a search. I just need to goto a certian part of the page when the page is loaded, but i cant place whatever javascript to do this in the head section, it must be in the body.
So you are not asking for any action from the user to request the search?

I did find the an answer I think.

using this example:

<form>
<input type="button" value="Click here!" onClick="alert('Thanks for visiting my site!');window.location='http://cnn.com'">
</form>

First you replace the alert() with your search function and then you replace window.location='http://cnn.com' with the url of your webpage and add #bookmarkName. Don't forget to seperate the two things with the ;

PhotoJoe

[edit]

I did some more testing and I found I could replace

window.location = your url plus #bookmarkName

with this

window.location = window.location + 'bookmarkName'

That way if you move or change the name of your page the coding would still work.

PhotoJoe

Sayian
11-03-2005, 08:53 AM
hmm .. i really appriciate your effort in helping me, but i am still having problems getting this to work right.

<a name="results"></a>
<span class="SectionHeader">Search Results </span>
<hr class="hr" />

How could i get the page to jump to the "results" section above, when it loads?

PhotoJoe47
11-03-2005, 02:22 PM
hmm .. i really appriciate your effort in helping me, but i am still having problems getting this to work right.

<a name="results"></a>
<span class="SectionHeader">Search Results </span>
<hr class="hr" />

How could i get the page to jump to the "results" section above, when it loads?
Ok Sayian,

I guess you better put a copy of your code for this page in your next post.

FYI:


code goes here



But use code and /code instead. Also select the line of code that starts the search process and make it bold and a different color. Do the same for where the search results are display.

BTW is the request and the results on the same page. I don't think you ever answered that question?

PhotoJoe

Pyth007
11-03-2005, 04:00 PM
PhotoJoe: I was wondering how some people were able to write tags like [code] without having it get interpreted, and then it hit me... seperate the first [ from the rest using some other tag! For eample, you would write:
[code] to get [code] displayed
(which, if you understand what I'm doing, you can imagine what a mess that example (with all those [B]'s) looks like!) Hense you don't need to use [ccode] and possibly confuse a newbie!

PhotoJoe47
11-03-2005, 04:37 PM
PhotoJoe: I was wondering how some people were able to write tags like [code] without having it get interpreted, and then it hit me... seperate the first [ from the rest using some other tag! For eample, you would write:
[code] to get [code] displayed
(which, if you understand what I'm doing, you can imagine what a mess that example (with all those [B]'s) looks like!) Hense you don't need to use [ccode] and possibly confuse a newbie!

I guess that is what happens when one newbie tries to help another newbie :)

But lets see if I can do this correctly.



code goes here



Ok it looks like I got it.

Thanks,
PhotoJoe