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

  • SEARCH
  • Home
  • 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 3723004
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:06:44+00:00 2026-05-19T06:06:44+00:00

A friend is linking my page from his site. As I need users to

  • 0

A friend is linking my page from his site.
As I need users to avoid caching when visiting my page, I want the url to have this form:

http://www.mypage.com/index.php?456646556

Where 456646556 is random number.

As my friend does not have installed php, how can I build the link with the random number using Javascript?

Also my friend asked me to give him just the url, with no further functions as his page is already loaded with them. Can it be done?

Thanks a lot

  • 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-19T06:06:46+00:00Added an answer on May 19, 2026 at 6:06 am

    I would add a parameter but you can leave it out if needed:

    var url = "http://www.mypage.com/index.php?rnd="+Math.random()

    or

    var url = "http://www.mypage.com/index.php?rnd="+new Date().getTime()

    Link:

    <a href="http://www.mypage.com/index.php?rnd=1" onClick="this.href=this.href.split('?')[0]+'?rnd='+new Date().getTime()">Mostly random</a>
    

    Note that if you have more than one assignment – for example in a loop, you need to add to the getTime since an iteration of the loop is faster than a millisecond:

    var rnd = new Date().getTime();
    for (var i=0;i<links.length;i++) {
       links[i].href = "http://www.mypage.com/index.php?rnd="+(rnd+i);
    }
    

    UPDATE to use the URL constructor with searchParams

    const addRnd = urls => {
      let rnd = new Date().getTime();
      return urls.map((urlStr,i) => {
        let url = new URL(urlStr);
        url.searchParams.set("rnd",rnd+i);  // in case called multiple times
        return url;
      });
    };
    const urls = addRnd( ["http://www.mypage.com/index1.php","http://www.mypage.com/index2.php","http://www.mypage.com/index3.php"])
    console.log(urls)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My friend done this below coding for custom control <a href=javascript:__doPostBack('id','msg');>click</a> now i want
I have a userscript (read: my Javascript on someone else's site) that allows users
my friend have a site whole written in aspx (i dont know much about
Friend's , I need to upload an image from android device to Facebook server
I've built a simple Friend model, which allows Users to have multiple friends. Here's
Hi friend I want to Develop an application for windows base First page of
friend i want that , i have xib and that xib name is mapper
Friend's I need help on loading the content alone in my page without going
friend's I have a task to place the horizontal scroll or swipe menu tabs
A friend show me this sample code to implement HTTP POST in C# and

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.