Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    y2k
    y2k is offline
    Junior Member
    Join Date
    Feb 2003
    Location
    Ireland
    Posts
    29
    Member #
    694
    ok, I'm sure I must be missing something here, but I can't see what. I'm using IE 5, so this should work, shouldn't it? My problem is, I have the following div:


    Code:
    <div id="div1" onMouseOver="info()">
    this is the content of div1</div>

    This is the style info in the style tag in the head:

    Code:
    div#div1{background-color:#ff9900; width:250;
        height:100; top:50; left:100; position: absolute}

    And this is the info() function, which is contained in the script tag, after I've finished the style tag:

    Code:
    var foo = document.getElementById("div1").style.top;
    alert(foo);

    The alert just returns a blank. If I put the style info for div1 in the style attribut of the div tag, ie <div style= ... , it works fine, so why can't it access it when I do it this way? I want to put this in an external style sheet, but I'm just putting it in the head for now as I'm just experimenting. Please, can somebody help me out here?

    Well, hope none of this sounds confusing, and I really hope somebody can help

    // added code tags

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Make sure you're using 5.5, not 5.0. You can also try document.all['div1'].style.top.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    y2k
    y2k is offline
    Junior Member
    Join Date
    Feb 2003
    Location
    Ireland
    Posts
    29
    Member #
    694
    Thanks, upgrading the browser isn't an option, even if I upgrade my browser, there's no guarantee that everybody who visits the site is going to be using 5.5. document.all is IE only, I'll be using that also for IE4 users as getElementById doesn't seem to work for that, but why did the alert return a blank?

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    No idea. Just a guess but try defining the function after the DIV tag.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Junior Member
    Join Date
    Feb 2003
    Posts
    11
    Member #
    626
    I ran into a similar problem a while back... but I think it was when using Mozilla 1.0. I'm using IE 6, and I believe it worked... .nonetheless.

    Anyways, the problem deals with the DOM (Document Object Model). The problem is, the style of the layer... in fact, the layer itself isn't defined in the DOM when you're outputting it to the browser using plain text. So... to have a page that just defines a <DIV> tag, won't work. You HAVE to use Javascript DOM functions to dynamically create the layer.

    Something like:
    Code:
      <SCRIPT LANGUAGE="javascript">
        _new_layerobj = document.createElement("div");
        _new_layerobj.setAttribute("id","div1");
        _new_layerobj.onMouseOver = "info()";
    
        document.body.appendChild(_new_layerobj);
      </SCRIPT>
    This is what seemed to work for me, but, of course, that means converting your entire site to be rendered in realtime using DOM functions. To make matters worse, it'll probably only work on IE4+ and Netscape 6+.

    Give it a shot, no guarantees it'll work, but might get you going in the right direction.

    - skubik.

  7. #6
    y2k
    y2k is offline
    Junior Member
    Join Date
    Feb 2003
    Location
    Ireland
    Posts
    29
    Member #
    694
    skubik, thanks for your reply. I haven't tried that out yet as I've been out sick, but I did want to ask you, you obviously seem to know alot about DHTML, don't suppose you could point me to where it is you learnt it? books, websites, ... ?

    thanks again for the post


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:31 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com