簡體   English   中英

如何在HTML中的href屬性上提供函數鏈接

[英]how to give a link with functions on the href atribute in html

我正在網站上創建以下鏈接

<a class="newimg forimgs " href="javascript:activateTab('newpost');javascript:mymodelII(newpostmesg);javascript:slidethecontent(contentinthetopicnewpost)" > New </a>

因此,當用戶單擊此鏈接時,它會更改選項卡。 當函數仍在href屬性中時,如何將鏈接更改為此類內容

文件:/// C:/Users/pavithra/Desktop/mysites/adminhome.html?newpost

您可以將tag的onClick()函數用於函數執行,並將href用作其鏈接。

<a class="newimg forimgs " href = "file:///C:/Users/pavithra/Desktop/mysites/adminhome.html?newpost" onclick="javascript:activateTab('newpost');javascript:mymodelII(newpostmesg);javascript:slidethecontent(contentinthetopicnewpost)" > New </a> 

在其容器上為超鏈接href創建一個單獨的函數。

<div class="hyperlink-container">
    <script type="text/javascript">
    function Go(){
      (function(){
        activateTab('newpost');
        mymodelII(newpostmesg);
        slidethecontent(contentinthetopicnewpost)
      })();
    } // this function will not affect another function because
      // it's applied to one container (div), on its top
    </script>
    <a class="newimg forimgs" href="javascript:Go()">
        New
    </a>
</div>

您可以使用onclick / onmouseover屬性或屬性來調用這些函數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM