简体   繁体   English

onclick=“location.href='manaliPackages.html'” 不工作

[英]onclick=“location.href='manaliPackages.html'” not working

I want to link my button with another page.我想将我的按钮与另一个页面链接。 I am using the code given below to do so.我正在使用下面给出的代码来执行此操作。

<button type="button" value="button text" class="commonBtn" 
onclick="location.href='manaliPackages.html'";> View Variations</button>

But it is not working... Why not?但它不工作......为什么不呢?

Your code should work just fine您的代码应该可以正常工作
(I'm assuming manaliPackages.html is a file in the same directory as the html file holding your code.) (我假设 manaliPackages.html 是与包含您的代码的 html 文件位于同一目录中的文件。)
For example:例如:
link/to/your/html/file.html contains the following: link/to/your/html/file.html包含以下内容:

<button type="button" value="button text" class="commonBtn" 
onclick="location.href='manaliPackages.html'";> View Variations</button>

Clicking this button would open: link/to/your/html/manaliPackages.html单击此按钮将打开: link/to/your/html/manaliPackages.html
Also, it is considered bad practice to use inline code, you should consider adding an event listener instead.此外,使用内联代码被认为是不好的做法,您应该考虑添加一个事件侦听器。
Please provide a snapshot of your browser console请提供您的浏览器控制台的快照

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM