Results 1 to 7 of 7

Thread: DHTML <div> stuff, cross browser pains...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537
    AARRRGGG!!
    I have this code that works in both browser w/ the exception that in Netscape it 'hides' my <a href>text.
    have a look at this in IE then Netscape to see what I meen.

    here is my code.

    <HTML>
    <HEAD>
    </HEAD>
    <BODY>

    <table align="right">
    <tr>
    <td><a href="#" onMouseOver="changeContent(this,'<FONT COLOR=red>Current events at north!</FONT>')"
    onMouseOut="changeContent(this,'Move the mouse pointer over this text')">North</a></td>
    </tr>
    <tr>
    <td><a href="#" onMouseOver="changeContent(this,'<FONT COLOR=red>Current events at south</FONT>')"
    onMouseOut="changeContent(this,'Move the mouse pointer over this text')">South</a></td>
    </tr>
    </table>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function changeContent(what,text) {
    if (document.all)
    object1.innerHTML = text;
    else if (document.layers) {
    document.open();
    document.write(text);
    document.close();
    }
    }
    //-->
    </SCRIPT>

    <DIV ID="object1">
    Current events show here!
    </DIV>
    </BODY>
    </HTML>
    if you have any suggestions that would be great.

    thanks and happy holidays
    pnj

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Your document.write is overwriting the contents of the page
    Mark
    -------------------

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537

    what do I do?

    Hi Mark,
    how do I fix it? I know you had given me some othere very cool code that worked but I liked this one becouse it passes variable into the function.
    I don't know this stuff well enough to marry the two version and make one killer version.

    the reason I like the passing variables version is that this will be used in an ASP page and those variables will be sent in from a database.

    either way if the code works I don't care I would just like it to be as short as possible.

    thanks again Mark
    pnj

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    I still think hiding/showing layers would be the easiest way


    have a look at this article:

    http://developer.irt.org/script/133.htm
    Mark
    -------------------

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537

    ???

    Mark,
    that code is hard for me to decifer.
    here is the code you sent me. as you see I have four different versions of text I need to show up.
    The only way I know how to do this is to write a new function for each <a href>.I think that is to much code.
    have a look at my code(your code, really) and see if you think it can be shortend.
    **************************************

    <HTML>
    <HEAD>
    <script language=javascript>
    var ntext;
    var otext;
    var North;
    var South;
    var Central;
    var SVI;
    function init()
    {
    if (document.all) {ntext = object1.style}
    if (document.all) {otext = object2.style}
    if (document.layers) {ntext = document.object1}
    if (document.layers) {otext = document.object2}
    }


    function oldText()
    {
    otext.visibility = 'hidden';
    ntext.visibility = 'visible';
    }

    function newText()
    {
    ntext.visibility = 'hidden';
    otext.visibility = 'visible';
    }
    //start of north current events
    function oldTextNorth()
    {
    var ntext;
    var otext;
    if (document.all) {ntext = object1.style}
    if (document.all) {otext = object3.style}
    if (document.layers) {ntext = document.object1}
    if (document.layers) {otext = document.object3}
    otext.visibility = 'hidden';
    ntext.visibility = 'visible';
    }

    function newTextNorth()

    {
    var ntext;
    var otext;
    if (document.all) {ntext = object1.style}
    if (document.all) {otext = object3.style}
    if (document.layers) {ntext = document.object1}
    if (document.layers) {otext = document.object3}
    ntext.visibility = 'hidden';
    otext.visibility = 'visible';
    }


    </script>
    </HEAD>
    <BODY onLoad="init()" vlink="red">
    <a href="#" onMouseover="newText()" onMouseout="oldText()">click here</A>
    <a href="#" onMouseover="newTextNorth()" onMouseout="oldTextNorth()">North</A>
    <a href="#" onMouseover="newText()" onMouseout="oldText()">South</A>
    <a href="#" onMouseover="newText()" onMouseout="oldText()">Central</A>

    <div ID="object1" STYLE="position:absolute;top:10;left:270">stuff</div>
    <div ID="object2" STYLE="position:absolute;top:10;left:270;visibility:hidden">new text</div>
    <div ID="object3" STYLE="position:absolute;top:10;left:570;visibility:hidden">North</div>
    <div ID="object4" STYLE="position:absolute;top:10;left:270;visibility:hidden">South Current Events</div>
    <div ID="object5" STYLE="position:absolute;top:10;left:270;visibility:hidden">Central Current Events</div>

    </BODY>
    </HTML>
    *****************************************
    right now I only have the 'newTextNorth' and the newText function working. but you can see where I would need to write two more functions for South and Central.
    it seems like I should be able to have one function and pass in the text I would like to show up...
    I just don't how to accomplish this.

    thanks for your help Mark
    pnj

  6. #6
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    That's YOUR code now!

    I put oText and Ntext at the top to make them 'global' so you dont need

    var ntext;
    var otext;
    if (document.all) {ntext = object1.style}
    if (document.all) {otext = object3.style}
    if (document.layers) {ntext = document.object1}
    if (document.layers) {otext = document.object3}

    in every function.



    have a look at this page. I think it might be simular to what you want to do:

    http://www.bratta.com/dhtml/scripts....&order=created
    Mark
    -------------------

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537

    yea! that looks great

    thanks Mark,
    I just took a quick glance at that page and the source, it looks like it should work perfect.
    I would take a closer look but I got the day off work and it's snowing in the mountains.

    thanks again
    happy holidays
    pnj

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width