SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Forum Mathematics Geek Agent Dwarf's Avatar
    Join Date
    Aug 2002
    Location
    Commonwealth of Pennsylvania
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calling an external file every 10 seconds

    Hello,

    I'm trying to accomplish something I can't figure out. Basically, I want Javascript to call an external file every ten seconds, and output the results. Is this possible?

    Example:

    javascript.php is the external file - when javascript.php is called, it checks if you have a window to open. If it does, javascript.php will output some javascript that opens the window.

  2. #2
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I won't ask why

    but one way would be to have a invisible Iframe in you page...
    <iframe id=myfram style="display:none">

    then have a function that calls itself every 10 secs...

    funtion callme(){

    settimeout(callme(),10000)
    }

    and in that function you submit the php file into the iframe... so it doesn't open a new window! and let it do what it does...

    myframe.location.href = "myphpfile.php"


    Umm, ps.... You just need to check my syntax and all that, I'm just thinking aloud here

    hope that gives you something to work with though

    cheerio
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  3. #3
    Forum Mathematics Geek Agent Dwarf's Avatar
    Join Date
    Aug 2002
    Location
    Commonwealth of Pennsylvania
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it working in IE, but not Netscape. Thanks for you help, but is there any solution that works on both netscape and IE?

  4. #4
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you need a solution that works in Netscape 4? If so, first ask yourself why you are still having to support a 5 year old browser, then bang your head on a wall for a bit out of sheer frustration at being held back by such a completely outdated piece of technology.

    Finished? Good

    What you need is a technique called "remote scripting", which basically means you can use javascript to grab information from a server without reloading the whole page (and without even having to use a frame or iframe). It is explained in detail here: http://www.ashleyit.com/rs/

    The library you want is JSRS, which is "known to work on Win9x, WinNT/2000, WinXP, Unix/Linux, and Mac with IE4+, NS4.x, NS6.x, Mozilla, and Galeon": http://www.ashleyit.com/rs/jsrs/test.htm

    I'm a fan of the remote scripting technique used for the dChat chat client on http://bodychat.org/dchat/ - basically it uses the DOM to append (and shortly afterwards delete) a <script> element every few seconds and the script element pulls in additional information from a server. Unfortuantely it doesn't work in IE5/Mac or NS4.

    Hope that helps.

  5. #5
    Forum Mathematics Geek Agent Dwarf's Avatar
    Join Date
    Aug 2002
    Location
    Commonwealth of Pennsylvania
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I've found a solution to this, all that is required is simple Javascript support. Even 5 year old browsers support it.

    If anyone is REALLY interested, if I have time, I will write a tutorial on it. But I don't really have time, otherwise.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •