C
Chris Leonard
Hi.
I've copied some code from a book which will enable me to make a layer
around a page, my aim is to do something a little more complex but this I
thought would get me started.
Anyway, I've run into a problem before I even start! The script works OK, it
runs the image in from the left hand side quite nicely, great. Problem I
have it always scrolls up to the top of the page, when the link I click
maybe 2 or 3 screens below (does that make sence?). I thought if I was to
add a name attribute to the link I could get the co-ordinates of this and
the screen will not reposition.
I tried this and I've come unstuck! I need to get the name of the link into
the slide function ..... can some bright spark out there help me out please,
I'm just no JavaScript expert!
TIA.
Chris
<SCRIPT language="JavaScript">
var layername, xgoal, ygoal, xhop, yhop, delay=5;
function checkDHTML() {
if ((parseInt(navigator.appVersion)>=4) &&
((navigator.appName !="Netscape" &&
navigator.appVersion.indexOf("X11") == 1) ||
(navigator.appName != "Microsoft Internet Explorer" &&
navigator.appVersion.indexOf("Macintosh") == -1)))
{ return 1}
else
{ document.location="nodhtml.htm"; return 0 }
}
function makeName(layerID) {
if (navigator.appName=="Netscape")
{ refname = eval("document." + layerID) }
else
{ refname = eval("document.all." + layerID + ".style") }
return refname
}
function slide() {
if ((parseInt(layername.left) != xgoal) ||
(parseInt(layername.top) != ygoal))
{
layername.left = parseInt(layername.left) + xhop;
layername.top = parseInt(layername.top) + yhop;
window.setTimeout("slide()", delay)
}
}
</SCRIPT>
HTML Part.
<DIV ID='picture0' STYLE='position: absolute; left: -500px; top: 10px;
width: 300; z-index: 1'>
<img src='pics/114974744.gif'>
</DIV>
<A name="link0" href="#" onClick="layername=makeName('picture0'); yhop=0;
ygoal=10; xhop=40; xgoal=100; slide()">
Click me</A>
I've copied some code from a book which will enable me to make a layer
around a page, my aim is to do something a little more complex but this I
thought would get me started.
Anyway, I've run into a problem before I even start! The script works OK, it
runs the image in from the left hand side quite nicely, great. Problem I
have it always scrolls up to the top of the page, when the link I click
maybe 2 or 3 screens below (does that make sence?). I thought if I was to
add a name attribute to the link I could get the co-ordinates of this and
the screen will not reposition.
I tried this and I've come unstuck! I need to get the name of the link into
the slide function ..... can some bright spark out there help me out please,
I'm just no JavaScript expert!
TIA.
Chris
<SCRIPT language="JavaScript">
var layername, xgoal, ygoal, xhop, yhop, delay=5;
function checkDHTML() {
if ((parseInt(navigator.appVersion)>=4) &&
((navigator.appName !="Netscape" &&
navigator.appVersion.indexOf("X11") == 1) ||
(navigator.appName != "Microsoft Internet Explorer" &&
navigator.appVersion.indexOf("Macintosh") == -1)))
{ return 1}
else
{ document.location="nodhtml.htm"; return 0 }
}
function makeName(layerID) {
if (navigator.appName=="Netscape")
{ refname = eval("document." + layerID) }
else
{ refname = eval("document.all." + layerID + ".style") }
return refname
}
function slide() {
if ((parseInt(layername.left) != xgoal) ||
(parseInt(layername.top) != ygoal))
{
layername.left = parseInt(layername.left) + xhop;
layername.top = parseInt(layername.top) + yhop;
window.setTimeout("slide()", delay)
}
}
</SCRIPT>
HTML Part.
<DIV ID='picture0' STYLE='position: absolute; left: -500px; top: 10px;
width: 300; z-index: 1'>
<img src='pics/114974744.gif'>
</DIV>
<A name="link0" href="#" onClick="layername=makeName('picture0'); yhop=0;
ygoal=10; xhop=40; xgoal=100; slide()">
Click me</A>