|
-
Apr 25th, 2007, 07:45 AM
#1
Thread Starter
Hyperactive Member
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
-
Apr 25th, 2007, 08:25 AM
#2
Re: Javascript Alter Layers left location
myelement.style.left = '110px';
-
Apr 25th, 2007, 08:42 AM
#3
Thread Starter
Hyperactive Member
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
-
Apr 25th, 2007, 08:45 AM
#4
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>
-
Apr 25th, 2007, 08:54 AM
#5
Thread Starter
Hyperactive Member
Re: Javascript Alter Layers left location
Code:
If LostAngel.Tag = "Programming" then
LostAngel.Caption = "Awake"
Else
LostAngel.Caption = "Dreaming of Code"
End If
-
May 1st, 2007, 09:34 AM
#6
Thread Starter
Hyperactive Member
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
-
May 1st, 2007, 09:47 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|