Search

Good evening,

I have created a blog. When someone adds a comment, I want the page to jump to an anchor - in case of success to the newly added entry - in case of an error to the form again

My idea is to add an anchor to the url (url#anchorname). I can add an anchor with

<form method="post" action="url#anchorname">

but in this case I can't because I only now which anchor after sending the form.

Is there a way to add the anchor while processing the page/form?

Thanks!

If you're reloading the page I presume you'll be using XSLT.

You can always check if the event has been submitted you add some inline javascript.

&lt;script>document.getElementById("comment-<xsl:value-of select='$commentID'/>").scrollIntoView()&lt;/script>

Or alternatively

window.location.hash = '#your-page-element';

both techniques should work if you're willing to put in a little bit of javascript since you would only know the anchor on load.

Thanks gunglien,

I am ok using javascript in this case – I have to anyway as I am using isotope for my layout and I need to jump to the anchor via javascript anyway after the page is loaded and layouted by isotope.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details