| Revision 20764,
1.1 KB
checked in by nanasess, 15 years ago
(diff) |
|
#601 (コピーライトの更新)
|
-
Property svn:eol-style set to
LF
-
Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 | function setTopButton(topURL) { |
|---|
| 2 | if(!topURL){ |
|---|
| 3 | topURL = "/"; |
|---|
| 4 | } |
|---|
| 5 | var buttonText = "TOPへ"; |
|---|
| 6 | var buttonId = "btn-top"; |
|---|
| 7 | |
|---|
| 8 | //ボタンの生成・設定 |
|---|
| 9 | var btn = document.createElement('div'); |
|---|
| 10 | var a = document.createElement('a'); |
|---|
| 11 | btn.id = buttonId; |
|---|
| 12 | btn.onclick = function(){location=topURL;}; |
|---|
| 13 | a.href = topURL; |
|---|
| 14 | a.innerText = buttonText; |
|---|
| 15 | |
|---|
| 16 | /* 背景色の設定 ---------------------*/ |
|---|
| 17 | //最初の見出しの背景色を取得、設定 |
|---|
| 18 | var obj = document.getElementsByTagName('h2')[0]; |
|---|
| 19 | var col = document.defaultView.getComputedStyle(obj,null).getPropertyValue('background-color'); |
|---|
| 20 | btn.style.backgroundColor = col; |
|---|
| 21 | |
|---|
| 22 | //省略表示用テキストの生成 |
|---|
| 23 | var spn = document.createElement('span'); |
|---|
| 24 | spn.innerText = obj.innerText; |
|---|
| 25 | obj.innerText = ""; |
|---|
| 26 | spn.style.display = "inline-block"; |
|---|
| 27 | spn.style.maxWidth = "50%"; |
|---|
| 28 | spn.style.overflow = "hidden"; |
|---|
| 29 | spn.style.textOverflow = "ellipsis"; |
|---|
| 30 | obj.appendChild(spn); |
|---|
| 31 | |
|---|
| 32 | //ボタンを追加 |
|---|
| 33 | btn.appendChild(a); |
|---|
| 34 | document.getElementsByTagName('body')[0].appendChild(btn);; |
|---|
| 35 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.