vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How would you code this? (meta redirect) (https://vborg.vbsupport.ru/showthread.php?t=220749)

Dribbles 08-12-2009 06:53 PM

How would you code this? (meta redirect)
 
I know you can do an autoredirect this way:

<META
http-equiv="refresh"
content="10;URL=http://www.******.com/forum/quiz_comics_v1">

but instead of just directing to 1 url, is there a way to have it auto-redirect to a random url out of a list of 10 url's? Like the person clicks the quiz page and it randomly picks a url from:

http://www.******.com/forum/quiz_comics_v1
http://www.******.com/forum/quiz_comics_v2
http://www.******.com/forum/quiz_comics_v3
http://www.******.com/forum/quiz_comics_v4
http://www.******.com/forum/quiz_comics_v5
http://www.******.com/forum/quiz_comics_v6
http://www.******.com/forum/quiz_comics_v7
http://www.******.com/forum/quiz_comics_v8
http://www.******.com/forum/quiz_comics_v9
http://www.******.com/forum/quiz_comics_v10

UKBusinessLive 08-12-2009 07:09 PM

Quote:

Originally Posted by Dribbles (Post 1866058)
I know you can do an autoredirect this way:

<META
http-equiv="refresh"
content="10;URL=http://www.******.com/forum/quiz_comics_v1">

but instead of just directing to 1 url, is there a way to have it auto-redirect to a random url out of a list of 10 url's? Like the person clicks the quiz page and it randomly picks a url from:

http://www.******.com/forum/quiz_comics_v1
http://www.******.com/forum/quiz_comics_v2
http://www.******.com/forum/quiz_comics_v3
http://www.******.com/forum/quiz_comics_v4
http://www.******.com/forum/quiz_comics_v5
http://www.******.com/forum/quiz_comics_v6
http://www.******.com/forum/quiz_comics_v7
http://www.******.com/forum/quiz_comics_v8
http://www.******.com/forum/quiz_comics_v9
http://www.******.com/forum/quiz_comics_v10

Hi Dribbles,

Not sure how to do it with the meta refresh, but with javascript its pretty easy

Code:

<script type="text/javascript">
       
        var urls = new Array("http://www.******.com/forum/quiz_comics_v1/", "http://www.******.com/forum/quiz_comics_v2/");
       
        function redirect()
        {
                window.location = urls[Math.floor(urls.length*Math.random())];
        }
       
        var temp = setInterval("redirect()", 3000);

</script>

Just enter the Urls in the

Code:

var urls = new Array
Inside the brackets add your urls

Go to here

Code:

var temp = setInterval("redirect()", 3000);
and change the 3000 value (Milliseconds) to more or less remember 1000 milliseconds is 1 second ;)

;)

Dribbles 08-12-2009 07:11 PM

thanks!! So I put this in the header area?

UKBusinessLive 08-12-2009 08:01 PM

Quote:

Originally Posted by Dribbles (Post 1866078)
thanks!! So I put this in the header area?

Please, Try at the end of your header ;)

let us know if it worked ;)

Stagehandspace 08-13-2009 01:57 AM

Quote:

Originally Posted by UKBusinessLive (Post 1866093)
Please, Try at the end of your header ;)

let us know if it worked ;)

Top of "headinclude" template would be best for this sort of coding as its meta related.

UKBusinessLive 08-13-2009 05:38 PM

Quote:

Originally Posted by Stagehandspace (Post 1866238)
Top of "headinclude" template would be best for this sort of coding as its meta related.

Thanks for the heads up ;)


All times are GMT. The time now is 12:22 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01029 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete