•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,523 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,396 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 561 | Replies: 4
![]() |
•
•
Join Date: Dec 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
I like this script
one click at a time....only one page at a time in order is what I would like it to do
Not random......
can anyone help me or is there a script i haven't found that does the same..???
Thanx so much for help.....
CODE:
<script>
<!--
/*
Random link button- By JavaScript Kit (http://javascriptkit.com)
Over 300+ free scripts!
This credit MUST stay intact for use
*/
//specify random links below. You can have as many as you want
var randomlinks=new Array()
randomlinks[0]="http://mysite/page/file"
randomlinks[1]="http://mysite/page/file"
randomlinks[2]="http://mysite/page/file"
randomlinks[3]="http://mysite/page/file"
randomlinks[4]="http://mysite/page/file"
function randomlink(){
window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
}
//-->
</script>
<form>
<p><input type="button" name="B1" value="Random Link >>" onclick="randomlink()"></p> </form>
<!--Uncomment below to use a regular text link instead
<a href="javascript:randomlink()">Random Link</a>
-->
one click at a time....only one page at a time in order is what I would like it to do
Not random......
can anyone help me or is there a script i haven't found that does the same..???
Thanx so much for help.....
CODE:
<script>
<!--
/*
Random link button- By JavaScript Kit (http://javascriptkit.com)
Over 300+ free scripts!
This credit MUST stay intact for use
*/
//specify random links below. You can have as many as you want
var randomlinks=new Array()
randomlinks[0]="http://mysite/page/file"
randomlinks[1]="http://mysite/page/file"
randomlinks[2]="http://mysite/page/file"
randomlinks[3]="http://mysite/page/file"
randomlinks[4]="http://mysite/page/file"
function randomlink(){
window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
}
//-->
</script>
<form>
<p><input type="button" name="B1" value="Random Link >>" onclick="randomlink()"></p> </form>
<!--Uncomment below to use a regular text link instead
<a href="javascript:randomlink()">Random Link</a>
-->
•
•
Join Date: Dec 2007
Posts: 75
Reputation:
Rep Power: 1
Solved Threads: 10
Try this:
<script>
<!--
var counter=0;
//specify random links below. You can have as many as you want
var randomlinks=new Array()
randomlinks[0]="http://mysite/page/file"
randomlinks[1]="http://mysite/page/file"
randomlinks[2]="http://mysite/page/file"
randomlinks[3]="http://mysite/page/file"
randomlinks[4]="http://mysite/page/file"
function randomlink(){
window.location=randomlinks[counter];
counter = (++counter)%randomlinks.length;
}
//-->
</script> >
This is incorrect since location is an object or a property of the window object and you are assigning a string to it. The correct way of doing it is
>
Don't see this would serve any purpose once the user has navigated away from the page after changing the
window.location=randomlinks[counter];This is incorrect since location is an object or a property of the window object and you are assigning a string to it. The correct way of doing it is
location.href = randomlinks[counter]; (window object is implied)>
counter = (++counter)%randomlinks.length;Don't see this would serve any purpose once the user has navigated away from the page after changing the
href... "I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
•
•
Join Date: Dec 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
I have this script in a header which may make a difference.... the button always shows up unless I go to an outside link...not sure but below it is....
This only executes the link the "var counter" is set to... like "3" or "5" or "0"
Can anyone see anything wrong with this ???
I cann't seem to get it to go to the next number when it is clicked again...
============================================================================
<script>
<!--
var counter=3;
//specify random links below. You can have as many as you want
var randomlinks=new Array()
randomlinks[0]="http://www.mysiteone
randomlinks[2]="http://www.mysitetwo
randomlinks[3]="http://www.mysitethree
randomlinks[4]="http://www.mysitefour
randomlinks[5]="http://www.mysitefive
function randomlink(){
location.href = randomlinks[counter];
}
//-->
</script>
=======================
please help me if you can...
thanx
This only executes the link the "var counter" is set to... like "3" or "5" or "0"
Can anyone see anything wrong with this ???
I cann't seem to get it to go to the next number when it is clicked again...
============================================================================
<script>
<!--
var counter=3;
//specify random links below. You can have as many as you want
var randomlinks=new Array()
randomlinks[0]="http://www.mysiteone
randomlinks[2]="http://www.mysitetwo
randomlinks[3]="http://www.mysitethree
randomlinks[4]="http://www.mysitefour
randomlinks[5]="http://www.mysitefive
function randomlink(){
location.href = randomlinks[counter];
}
//-->
</script>
=======================
please help me if you can...
thanx
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation ajax api asp blogger blogging blogs code combo cross-browser javascript menu with few lines of code dani daniweb data developer development dreamweaver dropdownlist firefox gdata google gpl home html internet javascript javascript smooth scrolling scroll smoothly window document position javascript tab menu with rounded corners generator key linux microsoft module msdn net news office openbsd product programming reuse rss serial software source tags vista web wysiwyg xml
- Will the jsp code will change if we connected to the oracle database ? (JSP)
- Code for Call the program in Visual Basic (Visual Basic 4 / 5 / 6)
- change the font/color of the selected text on a web page through javascript (JavaScript / DHTML / AJAX)
- Need help with one line of code :( (C++)
- how to change the the value of src in <embed> using javascript (JavaScript / DHTML / AJAX)
- change system date (Pascal and Delphi)
- Key stroke change (Visual Basic 4 / 5 / 6)
- creating our own C++ strcat() function, code reqd (C++)
- How to code a program that can show color text output??? (C)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: secure online form - javascript
- Next Thread: Function is undefined



Linear Mode