471,072 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,072 software developers and data experts.

Random window.open

Hi,

I would like to know if there is a way in php to randomize
the following url (www.domainsample.com used as example).

I have 4 different urls I would like to use, basically changing
every time the page is accessed.

<!--
function open_on_entrance(url,name)
{

new_window = window.open('www.domainsample.com','domainsample',
'menubar,resizable,scrollbars,dependent,status')
}
// -->
</script>

Any assistance would be great.

--
Thanks,

Wayne.
May 30 '06 #1
1 1241
Wayne wrote:
Hi,

I would like to know if there is a way in php to randomize
the following url (www.domainsample.com used as example).

I have 4 different urls I would like to use, basically changing
every time the page is accessed.

<!--
function open_on_entrance(url,name)
{

new_window = window.open('www.domainsample.com','domainsample',
'menubar,resizable,scrollbars,dependent,status')
}
// -->
</script>

Any assistance would be great.


I'm not sure what your question is. You ask if you can do something in PHP,
then post some javascript code.

If you're asking if you can generate the javascript code with randomized urls,
the answer is yes - put the url's you want to randomize in an array, call rand()
to get a random number between 0 and the number of array elements - 1 and write
the selected element into your javascript code.

And BTW - when using example domains, you should use www.example.com - which has
been reserved for that reason.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Heath | last post: by
16 posts views Thread by Jason | last post: by
1 post views Thread by Terry Haufler | last post: by
22 posts views Thread by Nhmiller | last post: by
4 posts views Thread by Christina | last post: by
4 posts views Thread by philly_bob | last post: by
5 posts views Thread by LayneMitch via WebmasterKB.com | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.