PDA

View Full Version : Open to a section of a dynamic page?


kellyblueyz
09-10-2007, 03:14 AM
I have been trying to figure out how to do this and I don't see it. Is there a way to generate a HTML page in CGI and have the browser focus move to a certain section? As if you were using the href NAME attribute.
(<a href=#section_name>).

My web survey has links to a side survey (this so people don't have to wade thru questions that don't pertain to them) but when the user "returns to survey", I don't know how to get it go back to the bottom of the page when it generates it. This is causing people to miss questions.

Thanks for any help or advice!

KevinADC
09-10-2007, 05:42 AM
However you do it on a static html page is the same way you do it with a dynamic page. To force the jump though you have to use javascript (although I don't know how myself) or append the name of the anchor you want the browser to jump to on the end of the url of the page.

http://www.example.com/survey.html#anchor_name

kellyblueyz
09-12-2007, 02:59 PM
Hi,
Thanks for the suggestion. I do try to access the page with the anchor as you have shown but it doesn't work. My guess is that is because the page doesn't exist when I call the script and so there is no anchor to go to until the page is generated.

Thanks I'll keep trying to figure something out :)

rwedge
09-12-2007, 11:13 PM
Since you need to handle this client side, you could use Javascript to target the anchor when the document loads<script type="text/javascript">
/*<![CDATA[*/
window.onload = function() {
location.href = '#target_id';
}
/*]]>*/
</script>

....

<a id="target_id"></a>

kellyblueyz
09-13-2007, 04:34 AM
Thanks! I will give that a try. It will really help!

KevinADC
09-13-2007, 06:45 PM
Hi,
Thanks for the suggestion. I do try to access the page with the anchor as you have shown but it doesn't work. My guess is that is because the page doesn't exist when I call the script and so there is no anchor to go to until the page is generated.

Thanks I'll keep trying to figure something out :)

As far as I know it should work. Wether a page is static or dynamic should be the same.