TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 110
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 67
  • Total: 68
  • @rjen

Quick js in block question

Started by 999, December 20, 2005, 04:10:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

999

I'm trying to get a scroll inside of a block, so I can use it for download links for right now.  My problem (other then not know js verywell) is that it only works in IE.  To get it to work in firefox/mozilla/etc, I've read I need to add onLoad="start();".  But I can't figure out how to add it into a phpbox (or a js/htmlbox) and get it to work.
echo '<marquee behavior="scroll" direction="down" height="50" scrolldelay="25" scrollamount="2" onmouseover="this.stop()" onmouseout="this.start()">
<a href="Downloads/test.rar">Test</a>
</marquee>';

Obviously from a phpbox, but I'll use either.  Any help? ???

If this is the wrong forum, I apologize.  Wasn't sure where to put it.

frisp

Have a look @ http://vf.unrealgamerz.org/ .I use a scrolling link block with graphics there. Is that what you're after? If so, I'll post the block code for you.

999

Yep, that's what I'm looking for. ;D

frisp

OK, please bear in mind, because this is on a subdomain, I link to the images on the main site (saves me a wee bit of space)ÂÃ,  ;D. It's just an HTML block.

<marquee direction="up" height="150" scrolldelay="25" scrollamount="1" onmouseover="this.stop()" onmouseout="this.start()">
<center><a href="http://www.unrealgamerz.org/" target="_blank"><IMG SRC="http://www.unrealgamerz.org/images/CZlinks/uglink.gif" width=88 height=31 alt="Unrealgamerz"></a><br>
<a href="http://www.tinyportal.net/" target="_blank"><img src="http://www.unrealgamerz.org/images/CZlinks/TP.gif" width=88 height=31 alt="TinyPortal"></a><br>
<a href="http://www.saintsservers.com/" target="_blank"><img src="http://www.unrealgamerz.org/images/CZlinks/saint.gif" width=88 height=31 alt="SaintsServers"></a><br>
<a href="http://www.unrealadmin.org/" target="_blank"><img src="http://www.unrealgamerz.org/images/CZlinks/ap.gif" width=88 height=31 alt="Unreal Admin"></a><br>
<a href="http://www.beyondunreal.com/" target="_blank"><img src="http://www.unrealgamerz.org/images/CZlinks/bu.gif" width=88 height=31 alt="BeyondUnreal"></a><br>
<a href="http://www.clanbase.com/news.php/" target="_blank"><img src="http://www.unrealgamerz.org/images/CZlinks/cb.gif" width=88 height=31 alt="Clanbase"></a><br>
</marquee><Br><Br>
<center>Link back to<Br><b>Virtual Fighters</b><Br>
<a href="http://vf.unrealgamerz.org/" target="_blank"><img src="http://www.unrealgamerz.org/images/CZlinks/VF.gif" alt="vf.unrealgamerz.org" width=88 height=31></a><p align="center">ÂÃ,  ÂÃ,  <textarea rows="3" cols="14"><a href="http://vf.unrealgamerz.org/" target="_blank"><img src="http://www.unrealgamerz.org/images/CZlinks/VF.gif" alt="vf.unrealgamerz.org" border=0 height=31 width=88></a></textarea>


Not sure if this is worth posting in the Code Snippets section? Bloc or IchBin can move it if so desired  :D

feline

I's not work with Opera (start / stop gives error and do nothing).
I's not work with FireFox (when limit height to smaler als inline height)

so what ?

Fel

frisp

#5
Well, I'm no PHP or HTML guru, just the oppositeÂÃ,  :uglystupid2: lol, I hack together what I need and play with the code to get the desired function. Best way to learn I think. If it doesn't work in opera or firefox with the limitations you've set, try adjusting the coding. It appears fine with firefox on the site for me and the guys who I built it for.ÂÃ,  ;D Maybe the guys here can give you a work around for it.

There is a free javascript that works a scrolling links system at http://javascript.internet.com/scrolls/link-hint-scroller-2.0.html I'll see if I can adapt the code so as It will work in Opera. No promises though. As for the height problem in firefox, I have no idea at the moment, unless it's to do with the graphics in the block.

feline

#6
well frisp .. i'ts ok.
for me .. not good enough  ;)
scroller for all browser is a simple javascript .. put it in a Iframe .. done.

sample:
Make a Iframe with heigt of 100 pixel.
Put in a small html (or php) script ..
<?php
echo '
 <html>
  <link rel="stylesheet" type="text/css" href="'
$theme_url'/style.css?rc1" />
  <script language="JavaScript" type="text/javascript" src="'
$theme_url'/news_ticker.js?rc1"></script>
 <head>

</head>
  <body class="tickerbg">
    <div class="tickerbg" style="margin: 0px -10px 0px -10px;">
    <div class="tickerbg" style="height:' 
$frmvh 'px;"></div>
    <div class="ticker"><span class="tickerbg">'  
... here your textlines ... '</span></div>
    <div class="tickerbg" style="height:' 
$frmvh 'px;"></div>
    </div>
    <script language="JavaScript1.2" type="text/javascript">
    <!--
    start_scroll()
    //-->
    </script>
  </body>
</html>'
;
?>


the javascrip:
var frame_name   = "Newsframe";
var timer        = null;
var scroll_tempo = 55;

function setCookie(wert)
{
  cook = "Scrollspeed=;";
  document.cookie = cook;
  cook = "Scrollspeed=" + wert + ";";
  document.cookie = cook;
}

function getCookie()
{
  wert = scroll_tempo;
  cook = document.cookie;
  valpos = cook.indexOf("Scrollspeed=")
  if (valpos >= 0)
  { valpos = valpos + 12;
    endpos = cook.indexOf(";")
    wert = Number(cook.substr(valpos, endpos-valpos));
  }
  return wert
}

function scrollable()
{
if(parent.frames[frame_name].document.body)
   return ((parent.frames[frame_name].document.body.scrollTop + parent.frames[frame_name].document.body.clientHeight) < parent.frames[frame_name].document.body.scrollHeight -10)
else
{
if(parent.frames[frame_name].document.height < 0)
   return true

return ((parent.frames[frame_name].pageYOffset + parent.frames[frame_name].innerHeight) < parent.frames[frame_name].document.height -10)
}
}

function step_scroll()
{
  window.clearTimeout(timer);
  timer = null;

  if(!scrollable())
    parent.frames[frame_name].scrollTo(0, 0);

  parent.frames[frame_name].scrollBy(0, 1);
  timer = window.setTimeout("step_scroll()", scroll_tempo);
}

function start_scroll()
{
  scroll_tempo = getCookie();
  timer = window.setTimeout("step_scroll()", 5);
}

function clickHandler(Handle)
{
  if (!Handle)
      Handle = window.event;
  if ((Handle.clientY < 15) && (scroll_tempo > 10))
  { scroll_tempo = scroll_tempo -5;
    setCookie(scroll_tempo);
  }
  if ((Handle.clientY > 85) && (scroll_tempo < 130))
  { scroll_tempo = scroll_tempo +5;
    setCookie(scroll_tempo);
  }
  if ((Handle.clientY > 15) && (Handle.clientY < 85))
  {
    if (timer)
    {
      window.clearTimeout(timer);
      timer = null;
    }
     else
    timer = window.setTimeout("step_scroll()", scroll_tempo);
  }
}

document.onmousedown = clickHandler;


works fine in IE, Opera and Firefox  :coolsmiley:

Fel

frisp

#7
 ;D Thanks feline, good job. I'm on nightshift at the moment, so didn't have time to play with the coding. Also I'm not comfortable working with Iframes. Been working with PHPNuke for too long.ÂÃ,  :D Hope this helps anyone else looking to do the same/similar. My code was hacked from a PHPNuke block I had modified in the past.

This website is proudly hosted on Crocweb Cloud Website Hosting.