Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

totally local page??

Status
Not open for further replies.

ssnapier

Technical User
Feb 17, 2001
67
US
I need a way to allow a user to input a refresh rate for a page and a link to be refreshed, then that data is written to a page where it is actually done.... but I need it to be done without the use of any sort of web host, has to be totally on the users local machine.... can't say what this is for, but I need a sloution. Hope this makes sense, I have to be kind of cryptic to protect what I am doing with it (nothing illegal I promise) HELP!!
 
I'm not very experienced in this kind of stuff, but I think that cookies will be the only answer to your question, store the data in a cookie and use javascript to set the refresh rate (maybe dynamic HTML writing in JavaScript...)
 
Can I assume that you want to link your visitors to a page that is not yours, yet set a refresh rate for that page to reload every x number of seconds / minutes.

I'll assume that is your case and say that obviously, you are not going to have any control over the headers or client side script in that page. Therefore, the only way you are going to have control over that page as far as reloading will be to launch it into a new window.

That way you can set a script in your page to tell the sub window to reload every x number of seconds / minutes.. And of course, if the visitor closes or navigates out of your page in the main window, the sub window will stop reloading..

If this sounds like a viable solution for you (opening the page in a new window), let me know and I'll send over the client side script to make it possible.

ToddWW :)
 
That sounds good.. I will not have to worry about navigation as this is for a real time event at a local charity event. I want folks to be able to have a page that will refresh as fast as they want it so they can see the changes, but like I said , this is going to be distributed on CD (and a few by email), and will be run from the local machine. If you can help me with that then send whatever you got my way!!

Thanks!
 
Here you go.. There must be a security issue with the reload() function outside of the host domain. I've used it extensively in my application across multiple windows, etc.. But in this case, I get a Permission Denied error when trying to issue the reload() method to the sub window outside of my domain. Wierd :cool:..

At any rate, I was able to make it work by using the location.href method. Of course, this is going to behave according to the cache settings in the browser.

Well, go ahead and load this page onto your server, or locally for that matter just to see how it works, then you can chop it up to fit into your specific app.

Code:
<html>
<head>
<script language=&quot;JavaScript&quot;>
<!--
var refreshUrl
var myWin
var refreshRate

//SET START AND END RATE FOR 
//REFRESH RATE OPTION LIST
var startrate = 5
var endrate = 60

function specialWin(form_ref) {
  refreshUrl = form_ref.url.value
  refreshRate = parseFloat(form_ref.rate.options[form_ref.rate.selectedIndex].value) * 1000
  myWin = window.open(refreshUrl,&quot;win1&quot;,&quot;width=400,height=300&quot;)
  setTimeout(&quot;newReload()&quot;, refreshRate)
}

function newReload() {
  if (!myWin.closed) {
    myWin.location.href = refreshUrl
    setTimeout(&quot;newReload()&quot;, refreshRate)
  }
}

function noSubmit() {
  return false
}

//-->
</script>
</head>
<body>
<form onSubmit=&quot;return noSubmit();&quot;>
URL: <input type=&quot;text&quot; name=&quot;url&quot; size=&quot;30&quot; value=&quot;[URL unfurl="true"]http://&quot;><br>[/URL]
Refresh Rate: <select name=&quot;rate&quot;>
<script Language=&quot;JavaScript&quot;>
<!--
for (var i = startrate; i < endrate+1; i++) {
  document.write(&quot;<option value='&quot; + i + &quot;'>&quot; + i + &quot;</option>&quot;)
}  
//-->
</script>

</select>
&nbsp;Seconds<br><br>
<input type=&quot;button&quot; value=&quot;Go There&quot; onClick=&quot;specialWin(this.form);&quot;>
</form>
</body>
</html>

Let me know if you have any questions. :)

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top