Results 1 to 7 of 7

Thread: Javascript Alter Layers left location

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    Javascript Alter Layers left location

    Hi all, I have a layer that I would like to control it's .LEFT value depending on resolutions...something like:

    if (window.screen.width < 1024) {
    LEFT=110;
    }
    if (window.screen.width > 1020) {
    LEFT=230 ;
    }
    if (window.screen.width > 1200) {
    LEFT=360;
    }

    Anyone have an idea on how to do this?
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Javascript Alter Layers left location

    myelement.style.left = '110px';

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    Re: Javascript Alter Layers left location

    I tried that and nothing happened...I used the following:
    Code:
    		<script language="Javascript">
    myElement = document.getElementById('Layer1');
    myelement.style.left = "5310px";
    </script>
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Javascript Alter Layers left location

    Oh, you need to set position:absolute as well.

    And don't use the language attribute; it's deprecated. Use type instead.
    HTML Code:
    <script type="text/javascript">
      var myElement = document.getElementById('Layer1');
      myElement.style.position = 'absolute';
      myElement.style.left = '5310px';
    </script>

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    Re: Javascript Alter Layers left location

    Fantastic! Thanks!
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    Re: Javascript Alter Layers left location

    Hey, I have another question. I came accross the following code:

    <HEAD>
    <SCRIPT language="JavaScript">
    <!--
    var browserName=navigator.appName;
    if (browserName=="Netscape")
    {
    alert("Hi Netscape User!");
    }
    else
    {
    if (browserName=="Microsoft Internet Explorer")
    {
    alert("Hi, Explorer User!");
    }
    }
    //-->
    </SCRIPT>
    </HEAD>

    How can I replace the alert messages, with another the javascript you showed me? I tried, and it won't work.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Javascript Alter Layers left location

    What would you like to replace them with? Something that gets outputted to the page?

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