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="JavaS cript">
var layername, xgoal, ygoal, xhop, yhop, delay=5;
function checkDHTML() {
if ((parseInt(navi gator.appVersio n)>=4) &&
((navigator.app Name !="Netscape" &&
navigator.appVe rsion.indexOf(" X11") == 1) ||
(navigator.appN ame != "Microsoft Internet Explorer" &&
navigator.appVe rsion.indexOf(" Macintosh") == -1)))
{ return 1}
else
{ document.locati on="nodhtml.htm "; return 0 }
}
function makeName(layerI D) {
if (navigator.appN ame=="Netscape" )
{ refname = eval("document. " + layerID) }
else
{ refname = eval("document. all." + layerID + ".style") }
return refname
}
function slide() {
if ((parseInt(laye rname.left) != xgoal) ||
(parseInt(layer name.top) != ygoal))
{
layername.left = parseInt(layern ame.left) + xhop;
layername.top = parseInt(layern ame.top) + yhop;
window.setTimeo ut("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="layern ame=makeName('p icture0'); 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="JavaS cript">
var layername, xgoal, ygoal, xhop, yhop, delay=5;
function checkDHTML() {
if ((parseInt(navi gator.appVersio n)>=4) &&
((navigator.app Name !="Netscape" &&
navigator.appVe rsion.indexOf(" X11") == 1) ||
(navigator.appN ame != "Microsoft Internet Explorer" &&
navigator.appVe rsion.indexOf(" Macintosh") == -1)))
{ return 1}
else
{ document.locati on="nodhtml.htm "; return 0 }
}
function makeName(layerI D) {
if (navigator.appN ame=="Netscape" )
{ refname = eval("document. " + layerID) }
else
{ refname = eval("document. all." + layerID + ".style") }
return refname
}
function slide() {
if ((parseInt(laye rname.left) != xgoal) ||
(parseInt(layer name.top) != ygoal))
{
layername.left = parseInt(layern ame.left) + xhop;
layername.top = parseInt(layern ame.top) + yhop;
window.setTimeo ut("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="layern ame=makeName('p icture0'); yhop=0;
ygoal=10; xhop=40; xgoal=100; slide()">
Click me</A>
Comment