如何将url放入按钮? Html - 记事本 [英] How can I put url in the button? Html - notepad

查看:91
本文介绍了如何将url放入按钮? Html - 记事本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的按钮中链接网址?因此,如果一个人点击按钮,它会转到另一个网站。

例如,



< nav类=主菜单> 
< ul>
< li>< a href =#home>主页< / a>< / li>
< li>< a href =#event>活动< / a>< / li>
< li>< a href =#members>会员< / a>< / li>

< li>< a href =#more>更多< / a>< / li>
<
< li>< a href =#contact>联系< / a>< / li>
< / ul>
< / nav>





我的尝试:



以及我如何在这里链接网址,你能否告诉我在哪里可以输入代码?

解决方案

您尚未显示按钮的代码。

但是你可以通过使用HTML锚标签来实现这一点,如下所示 -

 <   a     href   =  http://www.w3schools.com > 访问W3Schools.com!<   / a  >  



参考: HTML标签 [ ^ ]

如果你想拥有像外观一样的按钮,你可以尝试 -

没有javascript:

 <  表格    action   =  http://www.w3schools.com >  
< 输入 type = < span class =code-keyword> submit value = 这是一个按钮链接 >
< / form >



使用javascript:

 < ;  输入    type  < span class =code-关键字> = 按钮    value   = 这是按钮链接    onclick   =  window.location.href = 'http://www.w3schools.com' >  





希望,它有帮助:)


看看这个: HTML a href属性 [ ^ ]

如果你真的想要一个按钮就像一个链接,请阅读如何创建一个像链接一样的HTML按钮? [ ^ ]

How can I link url in my button? So if a person clicks on the button it goes to another website.
For example,

<nav class="main-menu">
                <ul>
                    <li><a href="#home">Home</a></li>
                    <li><a href="#event">Event</a></li>
                    <li><a href="#members">Member</a></li>
                  
		<li><a href="#more">More</a></li>
			<
                    <li><a href="#contact">Contact</a></li>
                </ul>
            </nav>



What I have tried:

And how I can link the url over here and could you please tell me where do I have to put the codes?

解决方案

You haven't shown the code for button.
However you can do this by just using the HTML anchor tag, something like following-

<a href="http://www.w3schools.com">Visit W3Schools.com!</a>


Reference: HTML a tag[^]
If you want have button like appearance then you can try -
Without javascript:

<form action="http://www.w3schools.com">
    <input type="submit" value="This is a button link">
</form>


With javascript:

<input type="button" value="This is button link" onclick="window.location.href='http://www.w3schools.com'">



Hope, it helps :)


Check this out: HTML a href Attribute[^]
If you really want a button to act like a link, read this How do I create an HTML button that acts like a link?[^]


这篇关于如何将url放入按钮? Html - 记事本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆