Issue
I am trying to use JavaScript function to navigate to another flask route.
this is the function
dateClick: function(info) {
alert('Date: ' + info.dateStr);
alert('Resource ID: ' + info.resource.id);
}
instead of alet I want it to navigate to this route
@app.route('/addPage')
def addPage():
return render_template('manual_entry.html')
Solution
I would try looking at windows.location.assign, it will change the tab URL to the one you give it.
If you wanted to without logging to the history of the current page (you can't use the back button then) then replace.
Example of functions:
// Variable function
let navigateTo = (url) => {
window.location.assign(url);
}
// Or specific function
let navigateToStackoverflow = () => {
window.location.assign("https://stackoverflow.com/");
}
Example of usage:
<button role="button" onclick="navigateTo('https://my-url.org')">Click for Escape</button>
<button role="button" id="anotherEscapeBtn">Or maybe this way?</button>
<script type="application/javascript">
document.querySelector('body').onclick = navigateToStackoverflow;
</script>
Answered By - Geekmoss
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.