title: url_for with onclick in flask
body: <pre><code>from flask import Flask,render_template,url_for
  
  app = Flask(__name__)
  
  @app.route("/")
  def index():
      return render_template("index.html")
  
  
  @app.route("/okay")
  def okay():
      return render_template("okay.html")
  
  
  
  if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  
  <p>this is index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;title&gt;Page Title&lt;/title&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;index&lt;/h1&gt;
      &lt;h2 onclick="{{ url_for('okay') }}"&gt;click me&lt;/h2&gt;
      &lt;h2&gt;&lt;a href="{{ url_for('okay') }}"&gt;click me&lt;/a&gt;&lt;/h2&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>click me</strong>
  this is not working 
  also 
  <strong>form action url_for is not working</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/52357417/change-route-and-send-message-using-socketio-but-socketio-is-working">change route and send message using socketio but socketio is working</a></p>
  
  <p>how to solve this issue?</p>