Home > flask, python > [flask] render a template and jump to an anchor

[flask] render a template and jump to an anchor

Problem
You render a page but you want to jump to an anchor on the rendered page.

Solution

Here is a route:

@app.route('/about/')
def fn_about():
    return render_template('about.html')

In the view add this (assuming you have jQuery):

<script> $(function(){ window.location.hash = "jump_here"; }); </script>

It’ll run once the HTML is loaded. Found it here.

Categories: flask, python Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: