Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 烧瓶点击href位置问题_Javascript_Html_Flask - Fatal编程技术网

Javascript 烧瓶点击href位置问题

Javascript 烧瓶点击href位置问题,javascript,html,flask,Javascript,Html,Flask,Im正在使用flask,并希望在用户单击按钮时将其重定向到特定的html页面: <button class="therapist-button" onclick='location.href='{{ url_for('therapist') }}''>Talk with your own personal therapist</button> 与你自己的私人治疗师交谈 我该怎么做?我越来越累了。“unterminated string litera

Im正在使用flask,并希望在用户单击按钮时将其重定向到特定的html页面:

<button class="therapist-button" onclick='location.href='{{ url_for('therapist') }}''>Talk with your own personal therapist</button>
与你自己的私人治疗师交谈

我该怎么做?我越来越累了。“unterminated string literal”错误首先:我认为由于它是直接位于标记上的侦听器,因此需要双引号:

<button onclick="yourFunction()">...</button>

第一:我认为,由于它是直接位于标记上的侦听器,因此需要双引号:

<button onclick="yourFunction()">...</button>

我想你想要的是:
window.location.href

但是URL应该被引用。如果有疑问,请检查生成页面的源代码。我想试试这样的东西:

onclick="window.location.href = '{{ url_for("therapist") }}'"
(未经测试,但希望有效)


虽然我个人会避免使用Javascript,只使用普通的
,但它可以像按钮一样设计,我想你需要的是:
window.location.href

但是URL应该被引用。如果有疑问,请检查生成页面的源代码。我想试试这样的东西:

onclick="window.location.href = '{{ url_for("therapist") }}'"
(未经测试,但希望有效)


虽然我个人会避免使用Javascript,只使用一个普通的
,但它可以像按钮一样设置样式,它可以消除错误,但不会重定向。我想可能有一个瓶子。这里有一个指向W3Schools的链接,它有一个简单的重定向()使用一个硬编码的URL进行尝试,以消除
URL\u中的任何问题,从而实现
功能。它可以消除错误,但不会重定向。我想可能有一个瓶子。这是一个指向W3Schools的链接,带有一个简单的重定向()使用一个硬编码的URL进行尝试,以消除您的
URL\u的任何问题,因为
函数下面有一条红色的错误线,但它可以工作…javascript Mant下面有一条红色的错误线,但它可以工作…javascript man