Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
DOM1 problem.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side
View previous topic :: View next topic  
Author Message
dmarusic



Joined: 15 Nov 2006
Posts: 3
Location: Varaždin

PostPosted: 06.12.2006 23:17    Post subject: DOM1 problem. Add user to your forum ignore list Reply with quote

Pozdrav!

Imam problem kod kodiranja manipulacije elementima. Koristim DOM1 za početak i imam neobičan problem i nekoliko pitanja.
Kod pokušaja čitanja vrijednosti
Code:
style.left
dobivam praznu poruku (preko alert()), a očekivao bih sadržaj prethodno u CSS-u definirane vrijednosti za traženi element.

Element je div s id-om "test" i prethodno je definiran relativno za
Code:
left = 20px
. Kod čitanja pomoću
Code:
alert(document.getElementById('test').style.left)
dobivam praznu poruku umjesto očekivanih 20px. Ako prethodno pridružim neku vrijednosti istom tom elementu koristeći
Code:
document.getElementById('test').style.left = 30;
, pozivanjem prethodno napisanog Alerta, dobivam vrijednost koju sam pridružio. Također se i element pomakne na točno određenu poziciju.
Ono što mi treba je kalkulacija pozicije i povećavanje pozicije za određenu vrijednost, no uz ovaj problem sam zapeo.

Hvala na pomoći, unaprijed.

DM

_________________
Do you feel punky, luck?
Back to top
View user's profile Send private message
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 06.12.2006 23:23    Post subject: Add user to your forum ignore list Reply with quote

Ako taj left inicijalno definiras css-om, onda tamo nema znaka jednakosti, vec se property postavlja ovako:
Code:
#test { position: relative; left: 20px; }

Ako je tako postavljeno, onda citanje sa style.left u javascriptu mora raditi... I to je jedini razlog koji mi ovako pada na prvu na pamet zasto ne radi...

Mozda da stavis negdje na net stranicu, pa das link, lakse bi bilo vidjeti konkretan kod i problem...

_________________
[+]I[+]am[+]my[+]own[+]religion[+]
Back to top
View user's profile Send private message Visit poster's website Twitter profile
dmarusic



Joined: 15 Nov 2006
Posts: 3
Location: Varaždin

PostPosted: 06.12.2006 23:40    Post subject: Add user to your forum ignore list Reply with quote

Ma jasno da nije = nego : Smile

Nemam gdje staviti na web u ovom trenutku. Evo sve.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
   <title>kattd dev</title>
   
   <style type="text/css">
   <!--
   *
   {
      margin: 0;
      padding: 0;
      border: 0;
   }
   .box
   {
      background-image: url(pozadina1.gif);
      background-repeat: no-repeat;
      width: 180px;
      height: 57px;
   }
   .bodyx
   {
      position: relative;
      background-image: url(bodyxback.gif);
      background-repeat: no-repeat;
      width: 158px;
      height: 17px;
      top: 28px;
      left: 11px;
   }
   .item
   {
      border: 0;
      position: relative;
      top: 20px;
      left: 21px;
   }
   -->
   </style>
   <script language="JavaScript" type="text/javascript">
   function movtest()
   {
   // document.getElementById('groups_item').style.left = 33;
   alert(document.getElementById('groups_item').style.left);
   document.getElementById('groups_item').style.left = 34+11;
   }
   </script>
</head>

<body>

<div id="groups_box"  class="box">
  <div id="groups_bodyx" class="bodyx">
  </div>
  <div id="groups_item" class="item"><a onclick="movtest()"><img src="item.gif" width="6" height="10" alt="strelica" /></a></div>
</div>

</body>
</html>

_________________
Do you feel punky, luck?
Back to top
View user's profile Send private message
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 07.12.2006 00:11    Post subject: Add user to your forum ignore list Reply with quote

http://www.quirksmode.org/dom/getstyles.html wrote:
The style property only reflects the inline styles of an element, so if you want to read out other styles you have to resort to other means.

http://www.quirksmode.org/dom/getstyles.html

Ili style definiraj inline, ili uzmi getStyles skriptu sa quirksmode-a koja moze citati i stilove koju su postavljeni drugim metodama...

_________________
[+]I[+]am[+]my[+]own[+]religion[+]
Back to top
View user's profile Send private message Visit poster's website Twitter profile
dmarusic



Joined: 15 Nov 2006
Posts: 3
Location: Varaždin

PostPosted: 07.12.2006 00:43    Post subject: Add user to your forum ignore list Reply with quote

Hvala lijepa i laku noć!

DM

_________________
Do you feel punky, luck?
Back to top
View user's profile Send private message
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 07.12.2006 00:44    Post subject: Add user to your forum ignore list Reply with quote

Ne možeš čitati style.bilošto property na elementu koji je te property-e dobio od stylesheeta (nisu bili inline)

Code:
var property = 'left'
var css = document.defaultView.getComputedStyle(element, null);
var value = css ? css.getPropertyValue(property) : null;


EDIT: baš sam spor Confused
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group