Looping HTML Link changer

Polak

I am cool.
Reaction score
83
Is there a code that makes a URL Link on a website change to another URL after like 1 hour or so?
 

UndeadDragon

Super Moderator
Reaction score
447
Do you mean a redirection script?
 

SFilip

Gone but not forgotten
Reaction score
634
Some more info would be good. Are you looking to do this server-side (with PHP for example) or client-side (JavaScript)?
 

Polak

I am cool.
Reaction score
83
I have no idea what your talking about filip, Just a code or something that changes the URL of a hyperlink to another site an hour later than back to the original site another hour later, so every hour the URL hyperlink changes to a different site.
 

TFlan

I could change this in my User CP.
Reaction score
64
Do it using a META refresher if you have no programming experience.

Code:
<meta http-equiv="refresh" content="3600;url=http://www.URL HERE.com">

Place that within the <head> ... </head> tags in your source.

** WOOT 1000th post... only took 4 years... **
 

Blackveiled

Formerly, Ban-Lord
Reaction score
157
Do it using a META refresher if you have no programming experience.

Code:
<meta http-equiv="refresh" content="3600;url=http://www.URL HERE.com">

Place that within the <head> ... </head> tags in your source.

** WOOT 1000th post... only took 4 years... **

Grats, lawl.
 
Reaction score
125
Do it using a META refresher if you have no programming experience.

Code:
<meta http-equiv="refresh" content="3600;url=http://www.URL HERE.com">

Place that within the <head> ... </head> tags in your source.

** WOOT 1000th post... only took 4 years... **

ahahahahah 4 years. Congratz.

lol:
KindaFail.png
 

TFlan

I could change this in my User CP.
Reaction score
64
Hey now... this is a milestone for me haha.

I only take an interest in this forum anyway. The rest bore me.

What's worse is this is the only support forum I'm active on, yet it takes me 4 years to deliver 1000 posts...


EDIT:: This must be a record for the slowest milestone reached on these forums...
 

TFlan

I could change this in my User CP.
Reaction score
64
How does that change the current URL to a new one?

:banghead: That's like asking how do we think, it just happens.

http://www.tizag.com/

Please read the HTML tutorials.

----

Code:
<meta http-equiv="refresh" content="3600;url=http://www.URL HERE.com">

That there is a meta tag. It describes the element inside the "http-equiv" with the value of the "content" parameter.

In this case the element is "refresh", which automatically refreshes the web browser after X amount of seconds. If the variable "url" is set, it will refresh the web browser to that URL.

Examples:
Code:
<meta http-equiv="refresh" content="60">
This will refresh the page every 60 seconds.

Code:
<meta http-equiv="refresh" content="60;url=URL HERE">
This will redirect the page after 60 seconds to the specified URL.

Code:
<meta http-equiv="refresh" content="0;url=URL HERE">
This will redirect the page immediately to the specified URL.

----

Some more lols... Posts Per Day: 0.73... which means I've been a member here for 1372.6 days...
 

duyen

New Member
Reaction score
214
Do it using a META refresher if you have no programming experience.

Code:
<meta http-equiv="refresh" content="3600;url=http://www.URL HERE.com">

Place that within the <head> ... </head> tags in your source.

** WOOT 1000th post... only took 4 years... **

All that would do is make it redirect to another page, not at all what he wants.

He wants a link to change, please re-read his post.
 

JerseyFoo

1/g = g-1
Reaction score
40
Who stays on the same page for an hour..

Do you mean a rotator script? Meaning if you visit at 2am, you may get a different link than from 1am. Also can do random.

HTML
Code:
<b>Click This: <script type="text/javascript" src="link.js"></script></b>

link.js
Code:
function setLink(){
  var numlinks = 2;
  var today = new Date();
  var x = ( today.getHours() % numlinks ) + 1;
  var url = '';
  var title = '';
  var insert = '';
  switch (x){
     case 1:
         url = 'thehelper.net/';
         title = 'TheHelper';
         break;
     case 2:
         url = 'hiveworkshop.com/';
         title = 'Hive Workshop';
         break;
      default:
         url = 'yomammasplace.org';
         title = 'Title This';
         break;
  }
  insert = '<a href="http://www.'+url+'" target="_blank">'+title+'</a>';
  document.write(insert);
}

setLink();

And voila, a rotator script. Be warned, it is off the top of my head.

Or, if you actually want to change the link after a certain amount of time has passed.

HTML
Code:
<a id="changelink" href="http://www.domain.com">Domain Dot Com</a>
... at bottom of page ...
<script type="text/javascript" src="script.js"></script>

script.js
Code:
function changeLink(){
  var link = document.getElementById('changelink');
  link.href = 'http://newurl.com';
  link.innerHTML = 'New URL Title'; // Can use .text instead ?
  link = null;
  clk = null;
}

var minutes = 60;
var seconds = 0;

var clk = setTimeout( changeLink, ( (minutes * 60) + seconds ) * 1000 );

Again, off top of head.

And if you want them to switch back and forth...
Code:
function changeLink(){
  var link = document.getElementById('changelink');
  link.href = 'http://newurl.com';
  link.innerHTML = 'New URL Title'; // Can use .text instead ?
  link = null;
  clk = setTimeout( changeLink2, linktime );
}

function changeLink2(){
  var link = document.getElementById('changelink');
  link.href = 'http://secondnewurl.com';
  link.innerHTML = 'Second New URL Title';
  link = null;
  clk = setTimeout( changeLink, linktime );
}

var minutes = 60;
var seconds = 0;

var linktime = ( (minutes * 60) + seconds ) * 1000;  minutes = null; seconds = null;
var clk = setTimeout( changeLink, linktime );
 

TFlan

I could change this in my User CP.
Reaction score
64
Script is close, but he wants "after 1 hour", so we need a timeout.

Link:
Code:
<a href="first/url/here.html" id="link1">Description Here</a>

JavaScript:
Code:
<script type="text/javascript">
<!--
    function changeLink(){
        document.getElementById("link1").href = "NEW/URL/HERE.HTML";
        document.getElementById("link1").innerHTML = "NEW DESCRIPTION HERE";
    }
// -->
</script>

Body Tag:
Code:
<body onLoad="setTimeout('changeLink()', 3600000)">

---

Sorry, made post before I saw your edited post Jersey. And no you can't use ".text"
 

JerseyFoo

1/g = g-1
Reaction score
40
Yea mixed up Interval and Timeout at first.

I personally don't trust body events, or onload for that matter.

<body onLoad="setTimeout('changeLink()', 3600000)">
setTimeout( changeLink, 3600000 ) is nicer according to jslint. I believe passing a string requires the JS to parse it first.
 

Polak

I am cool.
Reaction score
83
<a href="www.mylinkgoeshere.com" id="link1">Here</a>
<script type="text/javascript">
<!--
function changeLink(){
document.getElementById("link1").href = "www.newlinkhere.com";
document.getElementById("link1").innerHTML = "Here";
}
// -->
</script>
<body onLoad="setTimeout('changeLink()', 3600000)">

So I just put the actual link where I put the my link goes here stuff and post it in the HTML editor of my site?
 

TFlan

I could change this in my User CP.
Reaction score
64
oh jeez...

Put the <script> ... </script> between <head> ... </head> tags.

Put <a href="www.mylinkgoeshere.com" id="link1">Here</a> where you want your link to go, make sure to change the information to match what you want.

And replace your <body> tag with <body onLoad="setTimeout('changeLink()', 3600000)">
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top