折りたたみメニュー
-
0 名前: stage : 2007/08/06(月) 00:09 ID:fmO6fvbC sub-Ds
- "読む"をクリックすると下が開き文章が出現します。全部で3つの文章項目があります。ページに最初に訪れると全て閉じた状態になっているんですが、これを一番目の文章だけ始めに訪れた時に開いた状態にしておきたいんですがどうしてもわかりません。アドバイスをお願い致します。
<script type="text/javascript">
var enablepersist="on" var collapseprevious="yes"
var contractsymbol='<img src="fold_opn.gif">' var expandsymbol='<img src="fold.gif"> '
if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}
function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
for (i=0; i<rootobj.length; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}
function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}
function expandcontent(curobj, cid){
var dt = document.getElementsByTagName('dt');
for (var i = 0; i < dt.length; i++) {
dt[i].style.display = 'block';
}
curobj.style.display = 'none';
if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}
function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}
function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
statecollect[inc].innerHTML=expandsymbol
inc++
}
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}
function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}
document.cookie=window.location.pathname+"="+selectedItem
}
function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0"
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}
if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload
if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate;
</script>
</head>
<body>
<dl class="kigyou">
<dt>■文章タイトル</dt>
<dt onclick="expandcontent(this, 'sc1')"><a href="#">読む</a></dt>
<dd id="sc1" class="switchcontent">・企業の「認知度」を上げて、ビジネスチャンスを広げたい!ああああああああああああああああああ
</dd>
</dl>
<dl class="kigyou">
<dt>■文章タイトル</dt>
<dt onclick="expandcontent(this, 'sc2')"><a href="#">読む</a></dt>
<dd id="sc2" class="switchcontent">・企業の「認知度」を上げて、ビジネスチャンスを広げたい!あああああああああああああああああああ
</dd>
</dl>
<dl class="kigyou">
<dt>■文章タイトル</dt>
<dt onclick="expandcontent(this, 'sc3')"><a href="#">読む</a></dt>
<dd id="sc3" class="switchcontent">・企業の「認知度」を上げて、ビジネスチャンスを広げたい!
</dd>
</dl>
-
1 名前: Z ◆XTzyosZXcL : 2007/08/06(月) 00:09 ID:qU.Yy6UD sub-Cl
- 下記の続きですか?それとも、何かまた新しいお話でしょうか?同時進行はされないようにお願いします。
http://www.tagindex.com/cgi-lib/q4bbs/patio.cgi?mode=view&no=1294
関連する掲示板Q&A:
http://www.tagindex.com/bbs/qa05.html
なお、JavaScirptなどのクライアント側スクリプトは「そのスクリプトが実行できる環境」でないとにっちもさっちもいかない(下手するとその後の操作すら不可能になる)事態になりがちであることには十分注意してください。
よって、本案件についてはNOSCRIPT要素などでクライアント側スクリプト非対応環境でも問題なくページが閲覧できるような設計をされることを希望します。
参考資料の例:
http://www.zspc.com/documents/wcag10/#gl-new-technologies
http://www.kanzaki.com/docs/html/accessible.html
http://www.aao.ne.jp/column/
-
2 名前: 匿名 : 2007/08/06(月) 00:09 ID:YHwZMdJX sub-Cz
- 条件外のマルチポスト(同じ質問を複数の掲示板に投稿する行為)は禁止です。
http://www.usagi-js.com/bbs/jsforum.cgi?no=9493&reno=no&oya=9493&mode=msgview
>>1
例えばこの場合、どういう noscript 要素を入れたら良いとお考えですか。
-
3 名前: Z ◆XTzyosZXcL : 2007/08/06(月) 00:09 ID:qU.Yy6UD sub-Cl
- 色々考えましたけれど、もう片方で進行中のスレッド(http://www.tagindex.com/cgi-lib/q4bbs/patio.cgi?mode=view&no=1294
)の方がクライアント側スクリプト非対応により配慮した作りに思えてきました(参考にしたコメント:http://www.tagindex.com/cgi-lib/q4bbs/patio.cgi?mode=view2&f=1294&no=12
)ので、こちらのスレッドでの提案は取り下げさせていただきます。