|
Answer» I'm trying to add a randomizer, of sorts, to my page http://gags4myhag.blogspot.com/2010/03/add-joke.html
I'm doing this with arrays using the links provided by a few comments now, but I'd like to be able to just have the randomizer in the bottom left scroll to a random part of the page instead. I'd also like for visitors to be able to press the randomizer more than once to be taken to random locations within that page. I've ditched the arrays with links idea because the links of comments past page one lead nowhere, and the code would need to be updated too often.
So (finally), how do I create a javascript scroll link that can be clicked time and again with a seemingly random RESULT. I'd like for it to include about 10 different spots (25 pixels down, 50px, etc...)
Is this a start???
Code: [Select]function jumpScroll() { window.scroll(0,150); // horizontal and VERTICAL scroll targets }
<a href="javascript:jumpScroll()">Jump to another place on the page</a>
And here's the code I currently have in place for the Randomizer:
Code: [Select]<div style="display:scroll;position:fixed;bottom:0px;left:0px;"> <script language="JavaScript"> <!--
images = new Array(4);
images[0] = "<a href = 'http://gags4myhag.blogspot.com/2010/03/add-joke.html#IDComment63797934'><img src='http://i40.photobucket.com/albums/e250/jonsan32/random1.jpg' width='200' height='60' onmouseover=this.src='http://i40.photobucket.com/albums/e250/jonsan32/random.gif' onmouseout=this.src='http://i40.photobucket.com/albums/e250/jonsan32/random1.jpg' style='border:none;' alt='Click here to view a Joke Random!'/></a>";
images[1] = "<a href = 'http://gags4myhag.blogspot.com/2010/03/add-joke.html#IDComment63797847'><img src='http://i40.photobucket.com/albums/e250/jonsan32/random1.jpg' width='200' height='60' onmouseover=this.src='http://i40.photobucket.com/albums/e250/jonsan32/random.gif' onmouseout=this.src='http://i40.photobucket.com/albums/e250/jonsan32/random1.jpg' style='border:none;' alt='Click here to view a Joke Random!'/></a>";
images[2] = "<a href = 'http://gags4myhag.blogspot.com/2010/03/add-joke.html#IDComment63797577'><img src='http://i40.photobucket.com/albums/e250/jonsan32/random1.jpg' width='200' height='60' onmouseover=this.src='http://i40.photobucket.com/albums/e250/jonsan32/random.gif' onmouseout=this.src='http://i40.photobucket.com/albums/e250/jonsan32/random1.jpg' style='border:none;' alt='Click here to view a Joke Random!'/></a>";
images[3] = "<a href = 'http://gags4myhag.blogspot.com/2010/03/add-joke.html#IDComment64203837'><img src='http://i40.photobucket.com/albums/e250/jonsan32/random1.jpg' width='200' height='60' onmouseover=this.src='http://i40.photobucket.com/albums/e250/jonsan32/random.gif' onmouseout=this.src='http://i40.photobucket.com/albums/e250/jonsan32/random1.jpg' style='border:none;' alt='Click here to view a Joke Random!'/></a>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
// --> </script></div>
I guess I'd like a combination of these two sets of code, where the page might have to refresh and scroll with an onload property so that a new random link is present and ready to be pressed. If there are any other solutions that might work for me, throw 'em my WAY. I just want people to be able to see random jokes.
PS I'm just now figuring out how much I don't know about this stuff, and I NEED to seriously change the level of HTML experience I claim to have. Sorry. If you'd like any other info, let me know. THANK YOU!I think I can word this FAR more simply (sorry about the previous explanation. I just wanted to avoid not being detailed enough):
Simply stated--->
How do you make a link go to a page, then scroll down to a certain point indicated within the aforementioned link?
Thanks for any help you can provide.Found this script if this helps any
Code: [Select]<script type="text/javascript"><!-- // November 3, 2009, http://www.willmaster.com/ // Copyright 2009 Bontrager Connection, LLC function AutoScrollOnload() {
// SPECIFY how many pixels from the left // and how many down from the top to // automatically scroll the page.
var InFromLeft = 0; var DownFromTop = 364;
// No other customization required.
window.scrollTo(InFromLeft,DownFromTop); } function AddOnloadEvent(f) { if(typeof window.onload != 'function') { window.onload = f; } else { var cache = window.onload; window.onload = function() { if(cache) { cache(); } f(); }; } } AddOnloadEvent(AutoScrollOnload); //--></script>
And yes, I am determined :-)
|