SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Remote load HTML. Is it possible?

    Ok, I'll cut straight to the chase. I have a number of websites and forums, each has a banner that changes every 7 seconds at the bottom of each page. I can't edit java and I don't see the point in learning it just for this one issue.

    The problem I have is that with it being Java and HTML, each time I want to change or add a banner, I have to manualy change the code on each site.

    Is it possible to load the HTML code from one location onto each site?
    Maybe an easy to manage javascript that will insert this code?

    Any help would be great.

    Here is the unfinished code, I am in the middle of finalising it.
    The code is hosted on its own here

    The code is shown in the following page , all other locations are pretty much the same.

    Code:
    <script type=text/javascript src="http://www.UkVariety.co.uk/banner/div_construct2.js"></script>
    <script type=text/javascript>
    var _banners = new Array();
    function addBanner(_bannerHTML){
      _banners[_banners.length?_banners.length:0]=_bannerHTML;
    }
    addBanner("<a href='http://www.ukvariety.co.uk'><img border=0 alt='UkVariety.co.uk' src='http://www.ukvariety.co.uk/files/bannermanager/Banners/ukvariety.gif'></a>");
    addBanner("<a href='http://www.ps2designer.co.nr'><img border=0 alt='PS2 Designer' src='http://www.ukvariety.co.uk/files/bannermanager/Banners/ps2designer.gif'></a>");
    addBanner("<a href='http://www.proxyservers.co.nr'><img border=0 alt='Proxy Servers' src='http://www.ukvariety.co.uk/files/bannermanager/Banners/proxyservers.gif'></a>");
    addBanner("<a href='http://www.jameswingfield.com'><img border=0 alt='James Wingfield' src='http://www.ukvariety.co.uk/files/bannermanager/Banners/jameswingfield.gif'></a>");
    var div2 = new NewDiv2(window, "banner", _banners[0],0,0,50,50,500,"CENTER");
    var count=0; /* which one to start with */
    function doIt() {
    count++;
    count%=_banners.length;
    div2.setBody(_banners[count]);
    }
    setInterval('doIt()',7000);
    </script>
    </p>
    
    </head>
    <body>
    
    <script type=text/javascript>
    div2.output();
    </script>
    </body>

  2. #2
    Word Painter silver trophy Shyflower's Avatar
    Join Date
    Oct 2003
    Location
    Winona, MN USA
    Posts
    10,053
    Mentioned
    142 Post(s)
    Tagged
    2 Thread(s)
    First of all, you aren't using java. You are using javascript and there's a big difference.

    You can put javascript in an external file and call it out in your document where needed. If you want it to preload before the page, put it in your head section. If you want it to load on call out (mouseover, click... etc) you can put it within the page body at the place your have it now.

    Use this:

    Code:
     <script src="http://yourdomain.com/scriptfile/yourscript.js" type="text/javascript"></script>
    change "yourdomain" to your domain name, "scriptfile" to the directory where you will keep your javascripts and "yourscript.js" to the name you have given your script.
    Linda Jenkinson
    "Say what you mean. Mean what you say. But don't say it mean." ~Unknown

  3. #3
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Still confused...

    Sorry, I meant to say javascript, regardless of which I can write neither.

    Ok, if I take away all the HTML then I will be mostly left with the script that loads the javascript from my server. That seems to be what you are suggesting.

    To be honest, I dont know what the javascript I am using does. All the details are contained within the quote above.

    How do I load this code to a page with one code? So that I could put the code in all my websites and only have to change the one file. For example, I plan to update the banner on a weekly basis and I want to only have the one piece that needs to be altered, not every individual site.

    Could I put all this code into some form of javascript that could be loaded? if so, how would I do that?

    Many thanks


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
  •