inputタグやbuttonタグにonclickを使ってリンクを設定する方法

リンクを設定する方法は

<a href="index.html">遷移</a>

だが、今回紹介するのは、inputタグやbuttonタグに設定する方法だ。

inputタグ

<input type="button" onclick="location.href='index.html'" value="遷移">


<!-- 直前のページに戻る -->
<input type="button" onclick="history.back()" value="戻る">

input type submitには設定できないので注意

buttonタグ

<button onclick="location.href='index.html'">遷移</button>


<!-- 直前のページに戻る -->
<button onclick="history.back()">戻る</button>
(Visited 1,712 times, 1 visits today)

コメント

  1. vagina より:

    Howdy! This post couldn’t be written any better!

    Reading this post reminds me of my old room mate! He always kept
    talking about this. I will forward this article to him. Pretty sure
    he will have a good read. Many thanks for sharing!

  2. What i don’t understood is if truth be told how you’re now not actually a
    lot more neatly-favored than you might be now. You’re very
    intelligent. You know therefore significantly with regards to this subject, made me personally consider it from so many
    varied angles. Its like women and men aren’t
    involved until it is something to do with Lady gaga!
    Your individual stuffs nice. All the time care for it up!

  3. I’m not positive the place you are getting your information, however great topic.
    I must spend some time finding out more or understanding
    more. Thank you for excellent information I was looking for this information for
    my mission.

  4. It’s amazing to go to see this site and reading the views of
    all mates concerning this article, while I am also eager of getting knowledge.

タイトルとURLをコピーしました