0

In the website I am creating, I want to include a form that gets the information contained in the button the user presses and then sends information through flask. Then with render_templates it comes back to the same tab. The button that the user clicks is not a nav-button but a submit one. How can I add a bookmark so that the user goes back to the middle of the page and not the top every time he presses this button to send the form?

In my case, I am using flask. I use the following code:

@app.route("/me")
def me():
    return render_template("me.html",objeto=objeto)

I want to go to the middle part of "me.html" but I cannot add "me.html#middle_part" as a bookmark here...

So I cannot create a conventional bookmark... Any ideas?

What @Don Smythe explained helped me, but what if the button is not a navigation tab but a form? Then there is no "href" attribute where you can put the url_for function... Any help? I am referring to this question:

Link to a specific location in a Flask template

MTT
  • 341
  • 5
  • 17

1 Answers1

0

You can add an specific id to an element in your destination page, then just add #tagId to the end of your link. for example put this id in target page:

 <div id="tagId">...</div>

And your link must be like this

<a href="/somewhere#tagId">Link</a>
mzfr
  • 564
  • 4
  • 10
  • Yes, thanks! But my problem is that that the link is used with flask (library of python, do not know if you have used it before). The function render_templates will show the tab "me" going to me.html file. (See the code on the edit question) Maybe I can create a bookmark but that it doesnt have to be clicked? Dont know how to do it... – MTT May 06 '18 at 07:04
  • I hope it help you: https://stackoverflow.com/questions/17483125/how-to-use-redirecturl-forindex-with-id-to-reload-the-index-html-with-spec?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa @MTT – mzfr May 06 '18 at 07:14
  • Thank you! But I am not using links... So that is why this doesnt help me – MTT May 06 '18 at 09:31