HighDots Forums  

Re: Adding CSS units to an old JS Script

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Adding CSS units to an old JS Script in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SAM
 
Posts: n/a

Default Re: Adding CSS units to an old JS Script - 06-27-2008 , 05:44 PM






rfr a écrit :
Quote:
I am a cut-n-paste javascript user and trying to update this script.

I have tried adding +"px" to the barW and barH lines. But that didnt get it
to work.
This bellow works for me in Firefox,
you can put this script in the head of your page(s)

<script language="JavaScript1.2" type="text/javascript">

// Based on watermark script by Paul Anderson, CNET Builder.com.
// All rights reserved.

// and then ?
// it was no more working ... so ... the rights ...

var markW = 90, // pixels wide
markH = 40, // pixels high
markX = 99, // percent right
markY = 99, // percent down
markRefresh = 50; // milliseconds

var posX, posY, wMark, navDOM, markID;

function setVals() {
var barW = 0; // scrollbar compensation for PC Nav
var barH = 0;
if (navDOM)
{
if (document.height > innerHeight) barW = 20;
if (document.width > innerWidth) barH = 20;
}
else
{
innerWidth = document.body.clientWidth;
innerHeight = document.body.clientHeight;
}
posX = ((innerWidth - markW)-barW) * (markX/100);
posY = ((innerHeight - markH)-barH) * (markY/100);
}

function wRefresh() {
wMark.left = posX + (navDOM?pageXOffset:document.body.scrollLeft) +'px';
wMark.top = posY + (navDOM?pageYOffset:document.body.scrollTop) + 'px';
}

function markMe() {
// set common object reference
wMark = document.all ? document.all['waterMark'].style :
document.getElementById?
document.getElementById('waterMark').style :
document.waterMark;
navDOM = window.innerHeight; // Nav DOM flag
wMark.width = markW;
wMark.height = markH;
setVals();
window.onresize=setVals;
markID = setInterval ("wRefresh()",markRefresh);
}

window.onload=markMe; // safety for Mac IE4.5

</script>


This script works with an associated div somewhere (preferably at end)
in the body of the page :

<div id="waterMark" style="position:absolute">
<a href="#" onClick="window.scrollTo(0,0)">
top
</a>
</div>


--
sm


Reply With Quote
  #2  
Old   
rfr
 
Posts: n/a

Default Re: Adding CSS units to an old JS Script - 06-27-2008 , 06:32 PM






Thank you.

That does work in FireFox, Opera and Netscape. But it does not work in MSIE
7.0.

I have no idea why it doesnt work in MSIE 7.0

And since MSIE is such a large part of the visitor audience, it has to work
there too.

"SAM" <stephanemoriaux.NoAdmin (AT) wanadoo (DOT) fr.invalid> wrote

Quote:
rfr a écrit :
I am a cut-n-paste javascript user and trying to update this script.

I have tried adding +"px" to the barW and barH lines. But that didnt get
it to work.

This bellow works for me in Firefox,
you can put this script in the head of your page(s)

script language="JavaScript1.2" type="text/javascript"

// Based on watermark script by Paul Anderson, CNET Builder.com.
// All rights reserved.

// and then ?
// it was no more working ... so ... the rights ...

var markW = 90, // pixels wide
markH = 40, // pixels high
markX = 99, // percent right
markY = 99, // percent down
markRefresh = 50; // milliseconds

var posX, posY, wMark, navDOM, markID;

function setVals() {
var barW = 0; // scrollbar compensation for PC Nav
var barH = 0;
if (navDOM)
{
if (document.height > innerHeight) barW = 20;
if (document.width > innerWidth) barH = 20;
}
else
{
innerWidth = document.body.clientWidth;
innerHeight = document.body.clientHeight;
}
posX = ((innerWidth - markW)-barW) * (markX/100);
posY = ((innerHeight - markH)-barH) * (markY/100);
}

function wRefresh() {
wMark.left = posX + (navDOM?pageXOffset:document.body.scrollLeft) +'px';
wMark.top = posY + (navDOM?pageYOffset:document.body.scrollTop) + 'px';
}

function markMe() {
// set common object reference
wMark = document.all ? document.all['waterMark'].style :
document.getElementById?
document.getElementById('waterMark').style :
document.waterMark;
navDOM = window.innerHeight; // Nav DOM flag
wMark.width = markW;
wMark.height = markH;
setVals();
window.onresize=setVals;
markID = setInterval ("wRefresh()",markRefresh);
}

window.onload=markMe; // safety for Mac IE4.5

/script


This script works with an associated div somewhere (preferably at end) in
the body of the page :

div id="waterMark" style="position:absolute"
a href="#" onClick="window.scrollTo(0,0)"
top
/a
/div


--
sm



Reply With Quote
  #3  
Old   
rfr
 
Posts: n/a

Default Re: Adding CSS units to an old JS Script - 06-28-2008 , 02:45 PM



What changes to I need to make to this script to get it to also work in
MSIE?

"rfr" <rfrohrer (AT) iw (DOT) net> wrote

Quote:
Thank you.

That does work in FireFox, Opera and Netscape. But it does not work in
MSIE 7.0.

I have no idea why it doesnt work in MSIE 7.0

And since MSIE is such a large part of the visitor audience, it has to
work there too.

"SAM" <stephanemoriaux.NoAdmin (AT) wanadoo (DOT) fr.invalid> wrote in message
news:48655f3c$0$923$ba4acef3 (AT) news (DOT) orange.fr...
rfr a écrit :
I am a cut-n-paste javascript user and trying to update this script.

I have tried adding +"px" to the barW and barH lines. But that didnt get
it to work.

This bellow works for me in Firefox,
you can put this script in the head of your page(s)

script language="JavaScript1.2" type="text/javascript"

// Based on watermark script by Paul Anderson, CNET Builder.com.
// All rights reserved.

// and then ?
// it was no more working ... so ... the rights ...

var markW = 90, // pixels wide
markH = 40, // pixels high
markX = 99, // percent right
markY = 99, // percent down
markRefresh = 50; // milliseconds

var posX, posY, wMark, navDOM, markID;

function setVals() {
var barW = 0; // scrollbar compensation for PC Nav
var barH = 0;
if (navDOM)
{
if (document.height > innerHeight) barW = 20;
if (document.width > innerWidth) barH = 20;
}
else
{
innerWidth = document.body.clientWidth;
innerHeight = document.body.clientHeight;
}
posX = ((innerWidth - markW)-barW) * (markX/100);
posY = ((innerHeight - markH)-barH) * (markY/100);
}

function wRefresh() {
wMark.left = posX + (navDOM?pageXOffset:document.body.scrollLeft) +'px';
wMark.top = posY + (navDOM?pageYOffset:document.body.scrollTop) + 'px';
}

function markMe() {
// set common object reference
wMark = document.all ? document.all['waterMark'].style :
document.getElementById?
document.getElementById('waterMark').style :
document.waterMark;
navDOM = window.innerHeight; // Nav DOM flag
wMark.width = markW;
wMark.height = markH;
setVals();
window.onresize=setVals;
markID = setInterval ("wRefresh()",markRefresh);
}

window.onload=markMe; // safety for Mac IE4.5

/script


This script works with an associated div somewhere (preferably at end) in
the body of the page :

div id="waterMark" style="position:absolute"
a href="#" onClick="window.scrollTo(0,0)"
top
/a
/div


--
sm





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.