By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

Can someone fix this watermark cut-n-past script by Paul Anderson to work with a Transitional Doctype

P: n/a
rfr
Apparently the Transitional Doctype kills this script because the script
does not make proper use of units like "px".

It works well without a doctype statement. But once someone adds a
transitional doctype, the js script no longer works.

Can someone familiar with javascript bring it up-to-date so that it works
with current doctypes and post it here for others to make use of?

The whole HTML document including the js scrip follows ( this was a footer
on a section of my comunity web site: I added the doctype and "<br>" codes
to make a test platform of it);
================================================== =================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<!-- Standard Wgtn.net 1st Level Footer -->
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<HR style="color:#000000;" width="75%">
<div align="center">
<center>
<Table style="border-collapse: collapse; border-color:#111111;"
cellpadding="0" cellspacing="0">
<TR>
<TD vAlign="top">
<A Href="../index.htm">
<Img src="images/wgtnhome.jpg" alt="Wgtn Home" border="0" width="75"
height="34" hspace="10"></A>
</TD>
<TD>
<center>
<Font size="-1" face="Arial">
Questions, needs, and issues on Design or Function should be addressed to
the <A
Href="mailto:we*******@wgtn.net">We*******@wgtn.ne t</A>
<BR>
Designed by Rohrer & Associates 2006
</Font>
</center>
</TD>
</TR>
</Table>

</center>
</div>
<DIV id="waterMark" style="position:absolute"><a href="#"
onClick="window.scrollTo(0,0)">
<img src="images/top0112.gif" border="0" width="80" height="42"
alt=""></a></DIV>

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

<!--

// Based on watermark script by Paul Anderson, CNET Builder.com. All rights
reserved.
markW = 90; // pixels wide
markH = 40; // pixels high
markX = 99; // percent right
markY = 99; // percent down
markRefresh = 50; // milliseconds

// set common object reference
if (!document.all) document.all = document;
if (!document.all.waterMark.style) document.all.waterMark.style =
document.all.waterMark;

wMark = document.all.waterMark.style;
wMark.width = markW;
wMark.height = markH;
navDOM = window.innerHeight; // Nav DOM flag

function setVals() {
barW = 0; // scrollbar compensation for PC Nav
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);
wMark.top = posY + (navDOM?pageYOffset:document.body.scrollTop);
}

function markMe() {
setVals();
window.onresize=setVals;
markID = setInterval ("wRefresh()",markRefresh);
}

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

//-->

</script>
</body>
</html>
==============================
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
rfr
This revised version that I found does work with a transitional DocType
==============================================
<script type="text/javascript">

/*
Floating Menu script- Roy Whittle (http://www.javascript-fx.com/)
Script featured on/available at http://www.dynamicdrive.com/
This notice must stay intact for use
*/

//Enter "frombottom" or "fromtop"
var verticalpos="frombottom"

if (!document.layers)
document.write('</div>')

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")?
document.documentElement : document.body
}

function JSFX_FloatTopDiv()
{
var startX = 3,
startY = 480;
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.a ll[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x+"px";this.st yle.top=y+"px";};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop +
iecompattest().clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopLeft=function()
{
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : document.body.scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/8;
}
else{
var pY = ns ? pageYOffset + innerHeight : iecompattest().scrollTop +
iecompattest().clientHeight;
ftlObj.y += (pY - startY - ftlObj.y)/8;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 10);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopDiv();
</script>
==================================================
"rfr" <rf******@iw.netwrote in message
news:DJ******************************@prairiewave. com...
Apparently the Transitional Doctype kills this script because the script
does not make proper use of units like "px".

It works well without a doctype statement. But once someone adds a
transitional doctype, the js script no longer works.

Can someone familiar with javascript bring it up-to-date so that it works
with current doctypes and post it here for others to make use of?

The whole HTML document including the js scrip follows ( this was a footer
on a section of my comunity web site: I added the doctype and "<br>" codes
to make a test platform of it);
================================================== =================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<!-- Standard Wgtn.net 1st Level Footer -->
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br>
<HR style="color:#000000;" width="75%">
<div align="center">
<center>
<Table style="border-collapse: collapse; border-color:#111111;"
cellpadding="0" cellspacing="0">
<TR>
<TD vAlign="top">
<A Href="../index.htm">
<Img src="images/wgtnhome.jpg" alt="Wgtn Home" border="0" width="75"
height="34" hspace="10"></A>
</TD>
<TD>
<center>
<Font size="-1" face="Arial">
Questions, needs, and issues on Design or Function should be addressed to
the <A
Href="mailto:we*******@wgtn.net">We*******@wgtn.ne t</A>
<BR>
Designed by Rohrer & Associates 2006
</Font>
</center>
</TD>
</TR>
</Table>

</center>
</div>
<DIV id="waterMark" style="position:absolute"><a href="#"
onClick="window.scrollTo(0,0)">
<img src="images/top0112.gif" border="0" width="80" height="42"
alt=""></a></DIV>

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

<!--

// Based on watermark script by Paul Anderson, CNET Builder.com. All
rights reserved.
markW = 90; // pixels wide
markH = 40; // pixels high
markX = 99; // percent right
markY = 99; // percent down
markRefresh = 50; // milliseconds

// set common object reference
if (!document.all) document.all = document;
if (!document.all.waterMark.style) document.all.waterMark.style =
document.all.waterMark;

wMark = document.all.waterMark.style;
wMark.width = markW;
wMark.height = markH;
navDOM = window.innerHeight; // Nav DOM flag

function setVals() {
barW = 0; // scrollbar compensation for PC Nav
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);
wMark.top = posY + (navDOM?pageYOffset:document.body.scrollTop);
}

function markMe() {
setVals();
window.onresize=setVals;
markID = setInterval ("wRefresh()",markRefresh);
}

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

//-->

</script>
</body>
</html>
==============================

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.