After using a few different scripts found from Javascriptkit.com I compiled the following code. I thought someone else might want to use it.
Under the <HEAD> tag in default.asp Place this code:
Code: Select all
<script type="text/javascript">
<!-- hide from old browsers
function formHandler(form1){
var value = document.form1.site.options[document.form1.site.selectedIndex].value;
window.location.href = "default.asp?time="+value;
}
function getValue(varname)
{
// First, we load the URL into a variable
var url = window.location.href;
// Next, split the url by the ?
var qparts = url.split("?");
// Check that there is a querystring, return "" if not
if (qparts.length == 0)
{
return "";
}
// Then find the querystring, everything after the ?
var query = qparts[1];
// Split the query string into variables (separates by &s)
var vars = query.split("&");
// Initialize the value with "" as default
var value = "";
// Iterate through vars, checking each one for varname
for (i=0;i<vars.length;i++)
{
// Split the variable by =, which splits name and value
var parts = vars[i].split("=");
// Check if the correct variable
if (parts[0] == varname)
{
// Load value into variable
value = parts[1];
// End the loop
break;
}
}
// Convert escape code
value = unescape(value);
// Convert "+"s to " "s
value.replace(/\+/g," ");
// Return the value
return value;
}
// The time out value is set to be 10,000 milli-seconds (or 10 seconds)
var time = getValue("time");
//setTimeout(' document.location=document.location' ,time*1000);
var tempTime = time;
var parselimit=time;
function begintimer(){
if (!document.images)
return
if (parselimit==1)
window.location.reload() //="document.location"
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left till refresh"
else
curtime=cursec+" seconds left till refresh"
window.status=curtime
setTimeout("begintimer()",1000)
}
}
// end hide -->
</script>
Code: Select all
<script language="JavaScript">
if (tempTime==15){
document.write('<form name="form1">');
document.write('<select name="site" size=1 onChange="javascript:formHandler()">');
document.write('<option selected value="15">15 Seconds');
document.write('<option value="30">30 Seconds');
document.write('<option value="60">1 minute');
document.write('<option value="120">2 minutes');
document.write('<option value="300">5 minutes');
document.write('</select>');
document.write('</form>');
}
else if (tempTime==30){
document.write('<form name="form1">');
document.write('<select name="site" size=1 onChange="javascript:formHandler()">');
document.write('<option value="15">15 Seconds');
document.write('<option selected value="30">30 Seconds');
document.write('<option value="60">1 minute');
document.write('<option value="120">2 minutes');
document.write('<option value="300">5 minutes');
document.write('</select>');
document.write('</form>');
}
else if (tempTime==60){
document.write('<form name="form1">');
document.write('<select name="site" size=1 onChange="javascript:formHandler()">');
document.write('<option value="15">15 Seconds');
document.write('<option value="30">30 Seconds');
document.write('<option selected value="60">1 minute');
document.write('<option value="120">2 minutes');
document.write('<option value="300">5 minutes');
document.write('</select>');
document.write('</form>');
}
else if (tempTime==120){
document.write('<form name="form1">');
document.write('<select name="site" size=1 onChange="javascript:formHandler()">');
document.write('<option value="15">15 Seconds');
document.write('<option value="30">30 Seconds');
document.write('<option value="60">1 minute');
document.write('<option selected value="120">2 minutes');
document.write('<option value="300">5 minutes');
document.write('</select>');
document.write('</form>');
}
else if (tempTime==300){
document.write('<form name="form1">');
document.write('<select name="site" size=1 onChange="javascript:formHandler()">');
document.write('<option value="15">15 Seconds');
document.write('<option value="30">30 Seconds');
document.write('<option value="60">1 minute');
document.write('<option value="120">2 minutes');
document.write('<option selected value="300">5 minutes');
document.write('</select>');
document.write('</form>');
}
else {
document.write('<form name="form1">');
document.write('<select name="site" size=1 onChange="javascript:formHandler()">');
document.write('<option selected>Time not in list!');
document.write('<option value="15">15 Seconds');
document.write('<option value="30">30 Seconds');
document.write('<option value="60">1 minute');
document.write('<option value="120">2 minutes');
document.write('<option value="300">5 minutes');
document.write('</select>');
document.write('</form>');
}
</script>
Code: Select all
<form name="form1">
<select name="site" size=1 onChange="javascript:formHandler()">
<option value="15">15 Seconds');
<option value="30">30 Seconds
<option value="60">1 minute
<option value="120">2 minutes
<option value="300">5 minutes
</select>
</form>
You could also use this instead of the onChange value (but be sure to remove the onChange action from the selection menu):
<input type=button value="Refresh Now" onClick="formHandler()">
I also went further and changed every link in default.asp to pass the selected time when ever they were going to be redirected to default.asp. (I.E. Home, The sorting links) That required a bit of javascript that had to be entered for each link. That is quite a bit to be posting here. If someone has a little background in Javascript and wants some pointers reply here and I will get in contact with you.
I know the code is not clean, but we are running this on our Intranet where I tested it and I know it can be run. I do not claim this will work for you or be fast, but I thought maybe it will be of help to others.
I post this code assuming that you have some experience in javascript, even then you might be able to get by without any.