Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-27-2019, 04:29 PM   #1
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
Randomize Which JS Is Called?

I just want to thank everyone in advance for the question I'm asking, especially if you're able to help me out here.

Say I have three javascript files OR pieces of javascript I want to run. I don't care if I'm calling three files, or one with conditions.

How do I randomize it so user lands on the website, the command is executed randomly.

So

mypopup.js
advertiserpopup.js
anotheroneofmypopups.js

Is there a way to randomly call one of those?

Or perhaps use it in

allpopups.js = 3 codes, randomized per visit.

The goal is to not run both a CPM and my own popup at the same time.

Thank you!
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-27-2019, 04:48 PM   #2
Miguel T
♦ Web Developer ♦
 
Miguel T's Avatar
 
Industry Role:
Join Date: May 2005
Location: Full-Stack Developer
Posts: 12,472
Just don't with PHP
Quicker and easier.
__________________

Full Stack Webdeveloper: HTML5/CSS3, jQuery, AJAX, ElevatedX, NATS, MechBunny, Wordpress
Miguel T is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-27-2019, 04:51 PM   #3
incredibleworkethic
Confirmed User
 
incredibleworkethic's Avatar
 
Industry Role:
Join Date: Sep 2009
Posts: 2,302
Quote:
Originally Posted by Miguel T View Post
Just don't with PHP
Quicker and easier.
I modified this script (4 options, you can change to 3) and replace images with other JS

It worked!

But what is this php you speak of? :D I'm calling it in a wordpress theme. And the ads are in javascript to make the popup. Any ideas?



var picnumber = Math.floor((Math.random() * 4) + 1);

if (picnumber == 1){
img.src = '1.jpg';
} else if (picnumber == 2) {
img.src = '2.jpg';
} else if (picnumber == 3) {
img.src = '3.jpg';
} else {
img.src = '4.jpg';
}
incredibleworkethic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-27-2019, 06:55 PM   #4
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,224
I smoked a bit and I'm kind of rusty with this, but would it be something like this in PHP?:

<?php

$a=array("mypopup.js","advertiserpopup.js","anothe roneofmypopups.js");

shuffle($a);

echo '<script type="text/javascript" src="'("$a[0]")'"></script>';

?>

I know that there's a better way to randomize by picking out a random number then using that for the array number to use rather than using Shuffle, but it's easier and I don't think there will be much difference in load with 3 variables.
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
randomize, files, javascript, run, randomly, anotheroneofmypopups.js, allpopups.js, mypopup.js, advertiserpopup.js, call, randomized, popup, youpimp, time, cpm, executed, codes, visit, goal, conditions, question, called, advance, user, lands



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.