Forum Webmasterskie: Przesuwana zawartość menu - Forum Webmasterskie

Skocz do zawartości

Strona 1 z 1
  • Nie możesz napisać tematu
  • Nie możesz odpowiedzieć

Przesuwana zawartość menu

#1 Użytkownik nie jest zalogowany   Zakhary Ikona

  • Przedszkolak
  • Pip
  • Grupa Members
  • Postów 1
  • Rejestracja 17-maj 11

Napisano 17 maj 2011 - 15:25

Witam

Potrzebuję menu, które przy pomocy dwóch strzałek umożliwiałoby przesuwanie zawartości w prawo lub lewo.
Chciałem użyć ten skrypt:

Kod:
<style type="text/css"> 
a:link { 
    font-family: Arial, Helvetica, Verdana, sans-serif; 
    font-size: 15px; 
    color: red; 
    text-decoration: underline; 
} 
a:visited { 
    font-family: Arial, Helvetica, Verdana, sans-serif; 
    font-size: 15px; 
    color: red; 
    text-decoration: underline; 
} 
a:hover { 
    font-family: Arial, Helvetica, Verdana, sans-serif; 
    font-size: 15px; 
    color: black; 
    text-decoration: none; 
} 

</style> 

<script type="text/javascript"> 

//configure path for left and right arrows 
var goleftimage='lewyButton.gif' 
var gorightimage='prawyButon.gif' 
//configure menu width (in px): 
var menuwidth=300 
//configure menu height (in px): 
var menuheight=25 
//Specify scroll buttons directions ("normal" or "reverse"): 
var scrolldir="normal" 
//configure scroll speed (1-10), where larger is faster 
var scrollspeed=6 
//specify menu content 
var menucontents='<nobr><a href="http://www.dynamicdrive.com">Dynamic Drive</a> | <a href="http://www.javascriptkit.com">Javascript Kit</a> | <a href="http://www.codingforums.com">CodingForums.com</a> | <a href="http://www.builder.com">Builder.com</a> | <a href="http://freewarejava.com">Freewarejava.com</a></nobr>' 


////NO NEED TO EDIT BELOW THIS LINE//////////// 

var iedom=document.all||document.getElementById 
var leftdircode='onmouseover="moveleft()" onmouseout="clearTimeout(lefttime)"' 
var rightdircode='onmouseover="moveright()" onmouseout="clearTimeout(righttime)"' 
if (scrolldir=="reverse"){ 
var tempswap=leftdircode 
leftdircode=rightdircode 
rightdircode=tempswap 
} 
if (iedom) 
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-5000">'+menucontents+'</span>') 
var actualwidth='' 
var cross_scroll, ns_scroll 
var loadedyes=0 
function fillup(){ 
if (iedom){ 
cross_scroll=document.getElementById? document.getElementById("test2") : document.all.test2 
cross_scroll.innerHTML=menucontents 
actualwidth=document.all? cross_scroll.offsetWidth : document.getElementById("temp").offsetWidth 
} 
else if (document.layers){ 
ns_scroll=document.ns_scrollmenu.document.ns_scrollmenu2 
ns_scroll.document.write(menucontents) 
ns_scroll.document.close() 
actualwidth=ns_scroll.document.width 
} 
loadedyes=1 
} 
window.onload=fillup 

function moveleft(){ 
if (loadedyes){ 
if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){ 
cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px" 
} 
else if (document.layers&&ns_scroll.left>(menuwidth-actualwidth)) 
ns_scroll.left-=scrollspeed 
} 
lefttime=setTimeout("moveleft()",50) 
} 

function moveright(){ 
if (loadedyes){ 
if (iedom&&parseInt(cross_scroll.style.left)<0) 
cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px" 
else if (document.layers&&ns_scroll.left<0) 
ns_scroll.left+=scrollspeed 
} 
righttime=setTimeout("moveright()",50) 
} 


if (iedom||document.layers){ 
with (document){ 
write('<table border="0" cellspacing="0" cellpadding="2">') 
write('<td valign="middle"><a href="#" '+leftdircode+'><img src="'+goleftimage+'"border=0></a> </td>') 
write('<td width="'+menuwidth+'px" valign="top">') 
if (iedom){ 
write('<div style="position:relative;width:'+menuwidth+'px;height:'+menuheight+'px;overflow:hidden;">') 
write('<div id="test2" style="position:absolute;left:0;top:0">') 
write('</div></div>') 
} 
else if (document.layers){ 
write('<ilayer width='+menuwidth+' height='+menuheight+' name="ns_scrollmenu">') 
write('<layer name="ns_scrollmenu2" left=0 top=0></layer></ilayer>') 
} 
write('</td>') 
write('<td valign="middle"> <a href="#" '+rightdircode+'>') 
write('<img src="'+gorightimage+'"border=0></a>') 
write('</td></table>') 
} 
} 

</script>



Niestety pojawia się problem. Wartość:

document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-5000">'+menucontents+'</span>')

hidden sprawia, że zawartość MENU na DIV'ie w ogóle nie jest wyświetlana, a gdy ją usunę wszystko "wychodzi" poza menu.
Jak mogę to naprawić bądź, czy ktoś zna jakiś lepszy/prostszy kod na taki efekt? Osobiście nic ciekawego na internecie nie znalazłem
0

#0 Reklama

  • WebForum.pl
  • Grupa Advert

Napisano --



Strona 1 z 1
  • Nie możesz napisać tematu
  • Nie możesz odpowiedzieć

Użytkownicy przeglądający ten temat: 1
0 użytkowników, 1 gości, 0 anonimowych