Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7572267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:52:58+00:00 2026-05-30T15:52:58+00:00

I’m trying to create a page that, when refreshed, will randomly load a url

  • 0

I’m trying to create a page that, when refreshed, will randomly load a url from a list of URLs. The best way I have found to do this so far is to have PHP grab the line randomly from the file and then load it into an iframe. This also allows me to have a close button on a top bar that allows whatever page was loaded into the iframe to breakout.

The problem that I am having is that in firefox after a couple reloads the iframe just starts reverting to a cache and won’t load anything new. I’m guessing it’s a cache issue because pressing Ctrl+F5 will make the iframe load a new page.

I’ve tried put a bunch of anti cache meta tags in as well as a peice of javascript that I found on this article.

So far nothing has worked. Does anyone know a good workaround or see something wrong in my code (I’m very much a novice).

Thanks for any help!

Here is the code:

</html>

<head>
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="expires" content="FRI, 13 APR 1999 01:00:00 GMT">  
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script type="text/javascript">

function Ionload()
{

$(parent.document).find("iframe").each(function() {
    // apply the logic only to the current iframe only
    if(this.contentDocument == window.document) {
       // if the href of the iframe is not same as 
       // the value of src attribute then reload it
      if(this.src != location.href) {
        this.src = this.src;
      }
    }
});

}
</script>

<?php

class MyClass
    {
    function GetLine()
        {
            global $line;

            srand ((double)microtime()*1000000);
            $f_contents = file ("urlz");
            $line = $f_contents[array_rand ($f_contents)];

        }

    function PrintVar()
        {
            global $line;
            print $line;
        }
    }

MyClass::GetLine();

?>

<style type="text/css" media="all">
    html, body {
      height: 100%
    }
    body {
      margin: 0;
      overflow: hidden;
    }
    #topbar {
      height: 50px;
      width: 100%;
      border-bottom: 3px solid #666
    }
    #page {
      height: 100%;
      width: 100%;
      border-width: 0
    }
</style>

</head>
<body>

<div id="topbar">

<a href=<?php MyClass::PrintVar();?> target="_top">close</a>

</div>

</body>

<iframe id="page" name="page" onload="Ionload()" src=<?php MyClass::PrintVar();?> frameborder="0" noresize="noresize"></iframe>

</html>

Update:

With some help from GGG I got it fixed. Here is the change to the function:

function GetLine()
    {
        global $newline;

        srand ((double)microtime()*1000000);
        $f_contents = file ("urlz");
        $line = $f_contents[array_rand ($f_contents)];
        $newline = $line . "?foo=" . rand();

    }

I went with a random number instead of a sequence as I didn’t know how to carry a sequence from one reload to another but this works.

I also noticed that the problem still exists if firefox is refreshed in less than two seconds after page load, but I can live with that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:52:59+00:00Added an answer on May 30, 2026 at 3:52 pm

    Try tacking a dummy query string onto the URL so the browser is forced to skip the cache.

    For example, instead of loading www.google.com, load www.google.com?foo=N where N is a number that you increment with each load.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.