我是個新手,我正在做我的網站。我的主機服務是IPage。當我試圖用一個按鈕改變到網站的不同部分時,它不起作用。以下是我的代碼:
<button onclick='https://rgulewicz2438602. ipage.com/About.html'>About</button>
uj5u.com熱心網友回復:
onclick是對一個事件的呼叫,所以你需要在他身上放一個動作,而不是url。
要重定向到另一個頁面,你可以使用window.location,像這樣:
<button onclick='window. location="https://rgulewicz2438602.ipage.com/About.html"'>關于</按鈕>
uj5u.com熱心網友回復:
你應該使用一個錨標簽來改變一個頁面的位置,就像這樣:
< a class="btn" href='https: //rgulewicz2438602. ipage.com/About.html'>About</a>
然后你可以用css將其樣式化,使其看起來像一個按鈕
。一些例子的樣式可能是這樣的:
.btn {
display: inline-block;
padding: 4px 8px;
background: tomato;
color: white;
text-decoration: none;
uj5u.com熱心網友回復:
要打開一個網站,可以使用帶有JavaScript的window.open,或者最好使用一個屬性為target="_blank"
試一下:
。a {
background: #aaf;
border: 1px solid #000;
border-radius: 3px;
color: #000;
padding: 4px;
}
a:hover {
background: #ddf;
}
a:active {
background: #aaf;
}
<a href="https://rgulewicz2438602. ipage.com/About.html">About</a>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/333713.html
標籤:
