簡體   English   中英

如何將html按鈕鏈接到目錄中的另一個html文件?

[英]How to link html button to another html file in directory?

我正在嘗試將屏幕上的當前html頁面重定向到另一個html文件,這兩個文件共享相同的位置。

我知道有關此信息的在線信息很多,但對我來說不起作用,我的應用程序剛崩潰

該應用使用以下代碼從android中的.java文件加載html文件:

WebView view = new WebView(this);
        view.getSettings().setJavaScriptEnabled(true);
        view.loadUrl("file:///android_asset/htmlfile.html");
        setContentView(view);

這是我嘗試過的

<p class="btn animated fadeIn"><a href='android_asset/home.html' class="btn animated fadeIn">GO!</a></p>

我也嘗試過使用表單onclick

<form>
<input type="button" value="GO!" onclick="file:///android_asset/home.html" />
</form>

感謝幫助

試試這個:(通過第一頁的URL更改myDomain值);

 function goToInteralLink(path){ var myDomain = 'http://example.com'; window.location.href = myDomain + "/" + path; } 
 <form> <input type="button" value="GO!" onclick="goToInteralLink('android_asset/home.html')" /> </form> 

正如您所說的那樣,兩個文件都位於同一位置,因此請在下面使用此代碼(您只需從href屬性中刪除'android_asset /'):

<p class="btn animated fadeIn"><a href='home.html' class="btn animated fadeIn">GO!</a></p>

暫無
暫無

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

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