PDA

View Full Version : Merging Javascripts



godly.asian
Mar 14th, 2007, 07:46 PM
I am wondering if it is possible to merge two javascript functions together. If it is can someone tell me how to merge these two together:


<html>
<body>
<center>

<marquee behavior=scroll id="scroller" onmouseover='stop()' onmouseout='start()' speed='2' width="60%">
<a href="#"><img src="images/scroll/test/pic1"></a>
</marquee>


</center>
</body>
</html>


<a href="javascript:scroller.scrollAmount=scroller.scrollAmount*3-scroller.scrollAmount;">Faster</a>
<a href="javascript:scroller.scrollAmount=scroller.scrollAmount*10/7-scroller.scrollAmount;">Slower</a>

<a href="javascript:scroller.direction='left'; javascript:scroller.scrollAmount=scroller.scrollAmount*2;" onMouseover="window.location=this.href">Forward</a>
<a href="javascript:scroller.direction='right'" onMouseover="window.location=this.href">Backward</a>

Thanks

godly.asian
Mar 14th, 2007, 09:04 PM
can anyone help me?

ImperialSpider
Mar 14th, 2007, 10:32 PM
I copied and pasted this script into a notepad, and ran the script, it worked just fine for me. All I did was place the </body> portion at the end instead of in the middle.

Please be a little more specific on what you are expecting the code to do.



Imperial Spider

godly.asian
Mar 14th, 2007, 11:10 PM
I know that the script runs fine, I was wondering if you could combine the two javascripts

Merge:

javascript:scroller.scrollAmount=scroller.scrollAmount*2-scroller.scrollAmount;
with

javascript:scroller.direction='right

godly.asian
Mar 18th, 2007, 02:56 PM
um...can neone do this?

david_kw
Mar 18th, 2007, 05:19 PM
I'm not sure I understand the question, but do you mean something like this?



<script type="text/javascript">
function doBoth() {
scroller.scrollAmount=scroller.scrollAmount*2-scroller.scrollAmount;
scroller.direction='right';
}
</script>

<a href="javascript:doBoth();">Do Both</a>


david_kw

godly.asian
Mar 18th, 2007, 05:39 PM
yes something like this, but when mouse over, it speed up by 2. And when mouseout , it goes back to normal speed (/2).

david_kw
Mar 18th, 2007, 06:43 PM
Still not sure I understand the overall goal. :) But here is another attempt.



<script type="text/javascript">
function doBoth(multiplier) {
scroller.scrollAmount=Math.round(scroller.scrollAmount*multiplier);
scroller.direction='right';
}
</script>

<a href="#" onmouseover="doBoth(2);" onmouseout="doBoth(0.5);">Do Both</a>


david_kw

godly.asian
Mar 18th, 2007, 09:00 PM
thanks I finally got it...