javascript coding

Discussion in 'Web Design & Coding' started by Nickweb, Aug 22, 2007.

  1. Nickweb

    Nickweb Resident Filmaker Moderator

    Joined:
    Nov 7, 2003
    Messages:
    2,532
    Location:
    North Wales, Britain
    I'm having a bit of trouble with javascipt at the moment.

    What Id like to do is have a .js file that calls an image with a hyperlink, a google adsense banner, then another hyperlinked image.

    eg - IMAGE/GOOGLE BANNER/IMAGE you can see what I want on my website = www.filmsbynick.com/portfolio at the bottom of the page, I have an image linked to another site, a small silly little message which will be replaced with a google ad banner, and then another image. (dont say it, I know the images are for different things, but its all linked to one url, I know, i just messed up the coding, thats all okay?...back to topic now...)

    The reason I want to do this is so I can steamline my site, and update the header/footers of my web pages from one file, and I'm utterly hopeless at this type of thing, I've tried looking around for javascript tuts, but none seem to do what I want them to do

    If someone could whip up the code I need, and point to where I need to change filenames etc... that would be great. Thanks dudes
     
    Last edited: Aug 22, 2007
    Nickweb, Aug 22, 2007
    #1
    1. Advertisements

  2. Nickweb

    Nickweb Resident Filmaker Moderator

    Joined:
    Nov 7, 2003
    Messages:
    2,532
    Location:
    North Wales, Britain
    Ok, theres gotta be SOMEONE here who knows even basic Javascript, I've been looking over the net for some basics, but I havent really had the time for this. I have found how to call another js file from inside the main js file.

    Can someone please give me some code that will hyperlink a image in javascript?

    I know how to do it in html, but it needs to be in java so I can have the whole thing in one js file

    Please
     
    Nickweb, Sep 20, 2007
    #2
    1. Advertisements

  3. Nickweb

    Fenis-Wolf VIP Member

    Joined:
    Apr 30, 2003
    Messages:
    2,951
    Location:
    Ann Arbor, Mi
    Really you should do this in a programming language-not javascript.
    I would probably do it in php like so:
    Code:
    <? 
    include("header.html"); 
    include("content.html");
    include("footer.html");
    ?>
    
     
    Fenis-Wolf, Sep 20, 2007
    #3
  4. Nickweb

    Nickweb Resident Filmaker Moderator

    Joined:
    Nov 7, 2003
    Messages:
    2,532
    Location:
    North Wales, Britain
    All I need is a file that has a hyperlinked image, a js script (google ad) then another hyperlinked image.

    I know didly squat about php, could I have the footer of my page call the footer.php file, which in turn calls an image which is hyperlinked, the google ad js code, and then another hyperlinked image?

    very sorry if I'm not explaing this very well, and thanks for being patient, Feris
     
    Nickweb, Sep 20, 2007
    #4
  5. Nickweb

    Fenis-Wolf VIP Member

    Joined:
    Apr 30, 2003
    Messages:
    2,951
    Location:
    Ann Arbor, Mi
    Ok in the footer.html file you include the javascript for the Google ads (which Google provided you) and the HTML for your linked image. I don't understand why you're trying to do the hyperlinked image in javascript-is it for a roll over image? Or something else?
     
    Fenis-Wolf, Sep 21, 2007
    #5
  6. Nickweb

    Nickweb Resident Filmaker Moderator

    Joined:
    Nov 7, 2003
    Messages:
    2,532
    Location:
    North Wales, Britain
    ok, I see your point, I just had the idea for javascript as the google ad is javascript, but I see your point.

    Now, none of my pages use php apart from the feedback form, its all html based.

    how do I use the above code, and do I insert it where I need the footer?

    thanks again
     
    Nickweb, Sep 24, 2007
    #6
  7. Nickweb

    Fenis-Wolf VIP Member

    Joined:
    Apr 30, 2003
    Messages:
    2,951
    Location:
    Ann Arbor, Mi
    You make a file called index.php and copy the code I gave you. Thats it.
    You then put your header HTML into a file called header.html, and your main content into a file called content.html and then your footer stuff into footer.html.
    When someone vists your website, that code above pulls those three files together and presents it to the browser as a single page.
     
    Fenis-Wolf, Sep 24, 2007
    #7
  8. Nickweb

    Nickweb Resident Filmaker Moderator

    Joined:
    Nov 7, 2003
    Messages:
    2,532
    Location:
    North Wales, Britain
    Thanks for the help Feris, I'll give it a shot right now

    Edit: ok, I did as you said, put the above code in a index.php file, and made the header, content, and footer.html files.

    you can see the result here: http://www.files.filmsbynick.com/php/ now the thing is, I made my whole site in html, and I dont really want to have to re-make the whole thing in php, also, there seems to be no definitive break between the html files when pulled up by the index.php file.

    Is there a way to keep my html files at www.filmsbynick.com/beta/slick but have a php file at the bottom that will pull just the footer, and if so, how do I call the php file, and put it inside the html file?

    Incase my description above is as clear as mud, I've made a small visual aid below:


    -------------------------------------
    filmsbynick (header)
    -------------------------------------
    content here

    blah
    blah
    blah
    blah
    -------------------------------------
    footer section (maybe call php file here, and only here)
     
    Last edited: Sep 25, 2007
    Nickweb, Sep 25, 2007
    #8
  9. Nickweb

    Fenis-Wolf VIP Member

    Joined:
    Apr 30, 2003
    Messages:
    2,951
    Location:
    Ann Arbor, Mi
    You have to rename the html files to php and then append at the bottom of the file
    Code:
    <?
    include("footer.html");
    ?>
    
    I believe that should get you there-this does need to go in each file you want the footer.
     
    Fenis-Wolf, Sep 25, 2007
    #9
  10. Nickweb

    Nickweb Resident Filmaker Moderator

    Joined:
    Nov 7, 2003
    Messages:
    2,532
    Location:
    North Wales, Britain
    Ok, I did what you said. At first I wasnt too sure about just changing the file extension from htm to php, but I did some googling, and you were right, all hail Fenis!

    You can see the finished result on this page: http://www.filmsbynick.com/beta/slick/photographyphp.php I havent rolled this out across the whole site yet, but I will be doing so in the next few days

    once again, thanks, fenis, the footer inclusion will help me to keep my footer easy to maintain

    Edit #3 - Fenis, I freaking LOVE you for the php code snippets, I've now been able to 'include' my drop-down nav bar thing from a single file, so when I update my site, I wont have to go through every single page.

    I owe you many, many thanks indeed! :)

    oh, and I've finished updating the site, all images fixed, all working, I bow down to you for your help
     
    Last edited: Sep 26, 2007
    Nickweb, Sep 25, 2007
    #10
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. joebel

    Javascript Problems PLEASE HELP

    joebel, Mar 26, 2003, in forum: Networking and Internet
    Replies:
    7
    Views:
    1,465
    James
    May 1, 2003
  2. loribee59

    Can't install javascript plugin for FF 1.0

    loribee59, Jan 2, 2005, in forum: Networking and Internet
    Replies:
    10
    Views:
    1,497
    loribee59
    Jan 7, 2005
  3. stubby711

    Define a font in Javascript (clocks,dates)

    stubby711, Apr 15, 2005, in forum: Web Design & Coding
    Replies:
    5
    Views:
    2,762
    stubby711
    Apr 17, 2005
  4. D Schrute

    Javascript Dilemma

    D Schrute, Apr 16, 2005, in forum: Web Design & Coding
    Replies:
    1
    Views:
    1,244
    Cuddlez
    Apr 19, 2005
  5. Puck
    Replies:
    1
    Views:
    446
  6. Mike Dee
    Replies:
    1
    Views:
    396
    Mike Dee
    Aug 9, 2006
  7. Laurence

    Javascript

    Laurence, Mar 20, 2007, in forum: Computing
    Replies:
    1
    Views:
    322
Loading...