J
Jake j
To those of you who sent me working examples of js include routines,
much thanks. I see from them examples that what I'm trying to get to
requires a higher level of js knowledge than I've got. Here's what I'm
really trying to do:
I've been using a sliding banner javascript routine in several html
files and it works fine. Rather than duplicate the code in each file,
however, it would obviously be preferable to including the routine in a
js file. So, now, I'm asking how to do it with this particular code
which is different and more complicated than the simpler examples.
What this routine does is place a text message ("BannerText") on a web
page and reposition it as the page is scrolled so that the message does
not disappear from the window. The text is also linked to another page
(linkpage.htm). Here's the code. Please note that this works fine
within the html file. The help I need is in getting it to work by
putting as much of it as possible in a js file and using <script
type="text/javascript" src="slider.js"></script> and whatever else may
be necessary for this particular function to be implemented. (My feeble
attempt was: <a href="#" "positionit();"></a> but it's obviously more
complicated). Or, I need someone to tell me it can't be done.
<div id="staticbanner" style="position:absolute;">
<a href="linkpage.htm" target="_blank">BannerText</a>
</div>
<script>
//define universal reference to "staticbanner"
var crossobj=document.all? document.all.staticbanner :
document.getElementById?
document.getElementById("staticbanner") :
document.staticbanner
function positionit(){
//define universal dsoc left point
var dsocleft=document.all? document.body.scrollLeft :
pageXOffset
//define universal dsoc top point
var dsoctop=document.all? document.body.scrollTop :
pageYOffset
//define universal browser window width
var window_width=document.all?
document.body.clientWidth
: window.innerWidth
//if the user is using IE 4+ or NS6+
if (document.all||document.getElementById){
crossobj.style.left=parseInt(dsocleft)+
parseInt(window_width)-40
crossobj.style.top=dsoctop+120
}
//else if the user is using NS 4
else if (document.layers){
crossobj.left=
dsocleft+window_width-60
crossobj.top=dsoctop+130
}
}
setInterval("positionit()",200)
</script>
~ J
much thanks. I see from them examples that what I'm trying to get to
requires a higher level of js knowledge than I've got. Here's what I'm
really trying to do:
I've been using a sliding banner javascript routine in several html
files and it works fine. Rather than duplicate the code in each file,
however, it would obviously be preferable to including the routine in a
js file. So, now, I'm asking how to do it with this particular code
which is different and more complicated than the simpler examples.
What this routine does is place a text message ("BannerText") on a web
page and reposition it as the page is scrolled so that the message does
not disappear from the window. The text is also linked to another page
(linkpage.htm). Here's the code. Please note that this works fine
within the html file. The help I need is in getting it to work by
putting as much of it as possible in a js file and using <script
type="text/javascript" src="slider.js"></script> and whatever else may
be necessary for this particular function to be implemented. (My feeble
attempt was: <a href="#" "positionit();"></a> but it's obviously more
complicated). Or, I need someone to tell me it can't be done.
<div id="staticbanner" style="position:absolute;">
<a href="linkpage.htm" target="_blank">BannerText</a>
</div>
<script>
//define universal reference to "staticbanner"
var crossobj=document.all? document.all.staticbanner :
document.getElementById?
document.getElementById("staticbanner") :
document.staticbanner
function positionit(){
//define universal dsoc left point
var dsocleft=document.all? document.body.scrollLeft :
pageXOffset
//define universal dsoc top point
var dsoctop=document.all? document.body.scrollTop :
pageYOffset
//define universal browser window width
var window_width=document.all?
document.body.clientWidth
: window.innerWidth
//if the user is using IE 4+ or NS6+
if (document.all||document.getElementById){
crossobj.style.left=parseInt(dsocleft)+
parseInt(window_width)-40
crossobj.style.top=dsoctop+120
}
//else if the user is using NS 4
else if (document.layers){
crossobj.left=
dsocleft+window_width-60
crossobj.top=dsoctop+130
}
}
setInterval("positionit()",200)
</script>
~ J