SitePoint Sponsor

User Tag List

Results 1 to 21 of 21
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    New B Question: banner rotator conflict

    I am doing one of my first sites and having a problem with this script for an ad rotator:

    <APPLET CODE="KzmAdvertise" WIDTH="200" HEIGHT="435">
    <PARAM NAME="copyright"
    VALUE="Alex 'Kazuma' Garbagnati, kazuma@energy.it">
    <PARAM NAME="scriptfile" VALUE="advertise_2.txt">
    <PARAM NAME="imagesdir" VALUE="ads">
    <PARAM NAME="welcome" VALUE="Welcome to Let's Bus It">
    </APPLET>

    It gets blocked by a bunch of anti virus programs. Is there a way to fix this? Also is there a way to make the ads open in a new window? I know these are real newb questions, sorry.

    Thanks tons to whoever can help me!

  2. #2
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    why are you useing an applet for an adrotator? this is completely un-necessary and pointless. just use an iframe... that is what most other ad sites do,
    -ALL
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site

  3. #3
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, such a Noob. What's an iframe and do you have any links to examples of them?

    Thanks

  4. #4
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site

  5. #5
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see how you do a rotating ad with that? Thanks for the help so far.

  6. #6
    SitePoint Addict ALL's Avatar
    Join Date
    Oct 2005
    Location
    South Dakota
    Posts
    215
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    no, i was just saying that using applets for ads are completely stupid! iframes are way more convient and dont require you to click it to activate it... they also do not require any special plugins or anything and more browsers support them.

    but i am not 100&#37; sure what you mean by "rotating ads" as like it just refreshes the ad?
    Did I help you?
    You can repay me, support one of my projects (no money needed):
    JavaScript Wiki, Another Web Forum, Paranormal Site

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,832
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You would be more likely to get help with that Java applet in a Java forum as it has nothing whatever to do with javascript.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  8. #8
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just refreshing the ad would work... as long as the user could click on it and open a new window. Any idea on how to do this? Thanks again, All!
    felgall, see... I'm a newb : (

  9. #9
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone please help? I know this should be really simple.

  10. #10
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,832
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Try asking for help with the Java code in the Java forum. Many people who use Javascript don't know anything at all about Java (some don't even realise that it is a totally different language that has no relationship to Javascript whatsoever).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  11. #11
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It might be easier to advise you if you described the basis on which ads are changed.

  12. #12
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm pretty open on how the ads rotate. They can either rotate after a few seconds or just after each refresh.

  13. #13
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But is the rotation fixed or varied, perhaps even random? Do you want to start with the same ad each time, or a different one? Do you need to keep track of which ads have been displayed to avoid repeats? Are there naming conventions used on the ads that might simplify selection (like ad1.jpg, ad2.jpg, where just changing a number selects a new ad) or more randomly named where a hash of names would have to be kept? Questions like that need answers before it will be possible to narrow in on the best solution.

  14. #14
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would like it to be random and a new ad each time. It's not a big deal if it repeats. Right now there isn't a naming convention but I can easily make one. They're gifs and are all the same size. Like I said before, it can either rotate or just simply change when refreshed. They need to have a url and I would prefer it if the url opened up in a new window. Hope this makes sense and helps, thanks JVLB!

  15. #15
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you were to implement a naming convention that used a number to differentiate between files it would be easy to use JavaScript's Math.random() method to select a different one on each iteration (though, occasionally a file might repeat back-to-back, especially if there only a few files in the group).

    Opening in a new window could be problematic because of the popularity of pop-up blockers, which will prevent this. Otherwise, a separate window is easy enough. Since these are images, it might be more reliable to simply float an absolutely positioned div over the page with the image in it. Window chrome can be simulated on the div and the div can be given the ability to be dragged by the mouse, though such things will quickly escalate the complexity of the project.

    Every file has a unique URL, but do you mean a URL from a different domain than the main page? Or do you mean that the GIF's originate from different domains? (A domain is basically the first part of the URL, like www.domain_name.com.)

  16. #16
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have a link that would put me in the right direction to do the JavaScript's Math.random() method?

    Each picture is for local companys like book and grocery stores. So when the user clicks on the ad it opens up their website.

  17. #17
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I see what you mean by a URL; you want a link on every image. Unfortunately, that increases the complexity of the task. I think the approach I'd consider would be to place an array of images and their associated URL's in an external .js file. That would simplify maintenance, as you would only have to update the .js file. Rather than use a two dimensional array to store the URL in a separate array location, I'd store the page URL and image URL in one delimited string, then use String.split() to break out the two parts at run time.

    Math.random is simple to use. Invoking "Math.random();" will return a pseudo-random number between 0 and 1 (in other words, a decimal fraction). You can multiply that number by 10, for instance if you want a number from 0 to 9 and lose any digits to the right of the decimal with Number.toFixed(0), which returns a string (not a number) which then can be used to access the appropriate coordinates in the array. The following should give you the idea. Good luck.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    </style>
    <script type="text/javascript">
    var arr=new Array();
    arr[0]="gifURL1,businessPageURL1";
    arr[1]="gifURL2,businessPageURL2";
    arr[2]="gifURL3,businessPageURL3";
    arr[3]="gifURL4,businessPageURL4";
    arr[4]="gifURL5,businessPageURL5";
    arr[5]="gifURL6,businessPageURL6";
    arr[6]="gifURL7,businessPageURL7";
    arr[7]="gifURL8,businessPageURL8";
    arr[8]="gifURL9,businessPageURL9";
    arr[9]="gifURL10,businessPageURL10";
    
    function doWin(){
      var ndx=parseInt((Math.random()*10).toFixed(0));
      var urls=arr[ndx];
      var urls_arr=urls.split(',');
      alert(urls_arr[0]+'\n'+urls_arr[1]);
    }
    </script>
    </head>
    <body>
    <p>
    <a href="#" onclick="doWin();return false;">try it</a>
    </p>
    </body>
    </html>
    Technically, the script will work without toFixed, because of JavaScript's loose typing, but it's probably better to not get in the habit of expecting the interpreter to clean things up for you.
    Last edited by JVLB; Dec 30, 2006 at 00:04.

  18. #18
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks JVLB, I might try this out.

  19. #19
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, and by the way, it would be easy to direct the link to a new window (in HTML, not XHTML) by using the target="_blank" attribute in the link tag.

  20. #20
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,832
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by JVLB View Post
    Oh, and by the way, it would be easy to direct the link to a new window (in HTML, not XHTML) by using the target="_blank" attribute in the link tag.
    Although since opening a new window is a behaviour rather than content it is more correctly done using the Javascript window.open() commant rather than the deprecated HTML target attribute.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  21. #21
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Target="_blank", however, doesn't run afoul of popup blockers. Pragmatism has its purposes.


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
  •