/    Sign up×
Community /Pin to ProfileBookmark

Return var into a Div Tag

So here is my small problem…
Trying to make my page layers dynamic to the users window size,…
so my layers will always appears at the right x,y

<script language=”JavaScript”>
function findXvalue()
{
var winl = (screen.width);
if (winl = 800 ) winl = 197;
if (winl = 1024 ) winl = 309;
if (winl = 1152 ) winl = 373;
if (winl = 1280 ) winl = 437;
return winl;
}
var resizeX = 0;
resizeX = findXvalue();
</script>

<body>

<div id=”LayerACQ” style=”position:absolute; width:189; height:115; z-index:1; left: 197; top: 148;>


<table>
….
</div>

I need to make the ‘left:197;’ dynamic… as per the value in my function…

Tried:

<div id=”LayerACQ” style=”position:absolute; width:189; height:115; z-index:1; left: ‘ findXvalue(); ‘ ; top: 148;>

<div id=”LayerACQ” style=”position:absolute; width:189; height:115; z-index:1; left: ‘ resizeX ‘ ; top: 148;>

and a few others….

Still never works…. (on action, puts the laye to ‘0’ cuz it does not understand the value)

Thanks to any who can help

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@BigMoosieJun 23.2005 — Perhaps this will give you some ideas:

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;HTML lang="en"&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;HTML&lt;/title&gt;
&lt;META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;META name="Content-Script-Type" content="text/javascript"&gt;
&lt;META name="Content-Style-Type" content="text/css"&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;

&lt;DIV id="moose" style="width:20px;background-color:blue;"&gt;&lt;/DIV&gt;

&lt;SCRIPT type="text/javascript"&gt;
&lt;!--

document.getElementById("moose").style.width="300px";

//--&gt;
&lt;/SCRIPT&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;
Copy linkTweet thisAlerts:
@lp_rochonauthorJun 23.2005 — well, so true, didn't think of that...

Going to try it this week-end

If any as more ideas, don't hold them in ;-)
Copy linkTweet thisAlerts:
@scragarJun 23.2005 — [code=php]<script type="text/javascript">
function findXvalue() {
var winl;
switch(screen.width){
case 800:
winl = 197;
break;
case 1024:
winl = 309;
break;
case 1152:
winl = 373;
break;
case 1280:
winl = 437;
break;
default:
winl = screen.width * 0.3;
break;
};
document.getElementById("LayerACQ").style.left=winl+"px";
return true;
};
window.onload = findXvalue;
</script>[/code]
×

Success!

Help @lp_rochon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...