Re: [問題] 如何得知訊窗元件裡的資訊
※ 引述《terrybob (翔翔)》之銘言:
: ※ 引述《bennylu (Benny)》之銘言:
: : <script>
: : alert(document.getElementById('LayerBull').style.top);
: : </script>
: 剛剛的推文問題,找到原因了
: 因為我的css樣式表是用連結的…↓
: <link href="1.css" rel="stylesheet" type="text/css">
: = =如果css設定是在網頁中的話,而不是連結css樣式表裡,就可以讀到…
: 有辦法讀到樣式表裡的資料嗎? > <"
: 抱歉,問題多…
: ↓網頁中的id ↓樣式表中的
: <div id="LayerBull" class="Bulletin">....(asp程式所產生的表格)...</div>
: 請大家幫忙…感謝~(敬禮)
如果一定要用<link>來引入*.css
style.css
--
.divCSS{
position:absolute;
top:40px;
}
*.htm
--
<link rel="stylesheet" type="text/css" href="style.css" />
<script>
function getMyStyle(id,property){
element=document.getElementById(id);
if(document.all){
alert(element.currentStyle[property])
}else{
cs=document.defaultView.getComputedStyle(element,null);
alert(eval("cs."+property));
}
}
</script>
<div id="obj" class="divCSS">
text
</div>
<input type="button" value="position" onclick="getMyStyle('obj','position')" />
<input type="button" value="top" onclick="getMyStyle('obj','top')" />
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.132.7.82
※ 編輯: bennylu 來自: 220.132.7.82 (08/25 12:06)
推
08/25 12:20, , 1F
08/25 12:20, 1F
※ 編輯: bennylu 來自: 220.132.7.82 (08/25 12:48)
推
08/25 12:49, , 2F
08/25 12:49, 2F
推
08/25 13:15, , 3F
08/25 13:15, 3F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 4 之 4 篇):