超链接无法正常工作< input type = button [英] Hyperlink not working on <input type=button

查看:88
本文介绍了超链接无法正常工作< input type = button的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅下面的代码。

我正在使用搜索栏并添加了一些按钮。

只有搜索按钮的超链接才能正常工作。但其他按钮不会重定向其链接,而是重定向到搜索按钮的超链接。

没有搜索按钮的其他三个按钮将使用它们添加的单独超链接。
你能解决吗?



查看代码



http://pastebin.com/uEJyyvsh 解决方案

为什么要在表单中保留4个提交按钮。
搜索是唯一的提交按钮。将按钮类型的其余部分更改为仅按钮。



I)并且,添加 onlick =location.href ='您的网址'。像这样,

 < input type =buttonstyle =background-color:redvalue =Loginonclick = location.href =的 'http://本地主机/登录/'; > 

II)添加, onclick =javascript:window.open('http ://www.facebook.com/','_ blank');> 用于在新标签页中打开。

 < input type =buttonstyle =background-color:redvalue =Facebookonclick =javascript:window.open('http://www.facebook.com/', '_blank');> 

1) target =_ blank是可以通过提交按钮来实现。



2) formtarget =_ blank

但是,这里不需要4个提交按钮。有关详细信息,请查看此提交按钮表单属性 - W3学校

 < div class =widget search_keyid =directory_search_location-5> 
< div class =widget-wrap widget-inside>
< div class =search_nearby_widget what_fld_search>
< form style =position:relative; action =http:// localhost / wordpress /id =searchformclass =searchform_5509 allinonemethod =getname =searchform_5509>
< input type =hiddenvalue =listingname =post_type>
< input type =hiddenvalue =allname =mkey []>
< input type =textsize =100placeholder =Looking For ...class =searchpost placeholderid =search_near-15100name =svalue =onkeypress = tmpl_insta_search_widget('searchform_5509')onclick =tmpl_insta_search_widget('searchform_5509')>

< input type =hiddenvalue =a18247a9c8name =t>
< input type =hiddenvalue =ORclass =sgoname =relation>
< input type =submitstyle =background-color:redvalue =Searchonclick =tmpl_find_click(15100);类= SGO >
< input type =buttonstyle =background-color:redvalue =Registeronclick =javascript:window.open('http:// localhost / register /','_ blank') ;>
< input type =buttonstyle =background-color:redvalue =Loginonclick =javascript:window.open('http:// localhost / login /','_ blank') ;>
< input type =buttonstyle =background-color:redvalue =Facebookonclick =javascript:window.open('http://www.facebook.com/','_ blank );>
< / form>
< / div>
< / div>
< / div>

如果您真的想要登录,注册,脸书页面..
Give like这个。

 < a href =你的URL在这里> 
< input type ='button'value =Login>
< / a>


Please see the below code.

I am using a search bar and added some buttons with it.

Only hyperlink of search button is working properly. But other buttons are not redirecting their link instead they are also redirecting to hyperlink of search button.

without search button other three buttons will use their added separate hyperlink. Can you please fix it?

See the codes

http://pastebin.com/uEJyyvsh

解决方案

Why you are keeping 4 submit button inside a form. Search is the only submit button. Change rest of the button type to button only.

I) And, add onlick="location.href='Your URL'". Like this,

<input type="button" style="background-color: red" value="Login" onclick="location.href='http://localhost/login/';">

II) Add , onclick="javascript:window.open('http://www.facebook.com/', '_blank');"> for opening in new tab.

<input type="button" style="background-color: red" value="Facebook" onclick="javascript:window.open('http://www.facebook.com/', '_blank');">

1) target="_blank" is possible in anchor tag.

2) formtarget="_blank" is possible with submit button.

But, here no need of 4 submit button. For more info, check this Submit Button Form Attribute - W3 Schools

<div class="widget search_key" id="directory_search_location-5">
        <div class="widget-wrap widget-inside">
            <div class="search_nearby_widget what_fld_search">            
                <form style="position:relative;" action="http://localhost/wordpress/" id="searchform" class="searchform_5509 allinone" method="get" name="searchform_5509">
                    <input type="hidden" value="listing" name="post_type">
                    <input type="hidden" value="all" name="mkey[]">
                    <input type="text" size="100" placeholder="Looking For ..." class="searchpost placeholder" id="search_near-15100" name="s" value="" onkeypress="tmpl_insta_search_widget('searchform_5509')" onclick="tmpl_insta_search_widget('searchform_5509')">

                    <input type="hidden" value="a18247a9c8" name="t">
                    <input type="hidden" value="OR" class="sgo" name="relation">
                    <input type="submit" style="background-color: red" value="Search" onclick="tmpl_find_click(15100);" class="sgo">
                    <input type="button" style="background-color: red" value="Register" onclick="javascript:window.open('http://localhost/register/', '_blank');">
                    <input type="button" style="background-color: red" value="Login" onclick="javascript:window.open('http://localhost/login/', '_blank');">
                    <input type="button" style="background-color: red" value="Facebook" onclick="javascript:window.open('http://www.facebook.com/', '_blank');">
                </form>
            </div>
        </div>
</div>

If you really want to go to login,register, facebook page.. Give like this.

<a href="Your URL Here">
    <input type='button' value="Login">
</a>

这篇关于超链接无法正常工作&lt; input type = button的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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