SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    Does anyone know how I can rotate the following code so that every time the page is loaded it rotates a different .js url each time?

    <script language="JavaScript" type="text/javascript" src="http://www.whatever.com/popads/logicsite.js">
    </script>

    The above code is in the <head> of my page, and I just have to find a way to rotate the .js url. Any help would be greatly appreciated.

    Shawn

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Do you need to rotate it for each user, or if one user views it and then another user views it, do you want it to rotate as well? If the latter, you'll need a server-side script. Otherwise, it should be doable with cookies and document.write().
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I just need it to rotate the javascript every visit to the page. Do you know how I could do this?

  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You didn't answer my question. Is it okay if two different people visiting your site one after another see the same thing as long as the same person visiting your site multiple times will see the rotating content?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  5. #5
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They won't, as the javascript I want to rotate already sets a cookie to make sure the same person does not see the same pop-up more than twice in a 24 hr period.

    Thank you

  6. #6
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ah, so you want to rotate the content for different users. Unfortunately, you can't do that sort of thing with JavaScript. Think about it: JavaScript runs on the client's browser. How can a program running on someone's browser affect what someone else sees in their browser? JavaScript prevents any such effects as a matter of security.

    You'll need to look into a server-side script to do this sort of thing.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  7. #7
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you!

    I have found a server-side script that works great for what I want to do. I have it working right now - Thanks!

    I know you cannot execute a server-side script on a cgi produced page, but is there anything I can use on a .cgi page that could rotate the javascript? I doubt there is, but if so let me know.

    Thanks again,
    Shawn

  8. #8
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by techno1
    is there anything I can use on a .cgi page that could rotate the javascript? I doubt there is, but if so let me know.
    CGI programs can generate JavaScript as easily as they can HTML. It's just a matter of editing the script to output what you want.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •