SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2008
    0 Post(s)
    0 Thread(s)


    Hi guys, how r u doing?
    I have to show my website on monday,
    we got basic php at college and no javascript yet.
    But we are allowed to use any java script we want.
    we learnt to do the following:
    main folder: index.php, contactus.php etc
    IN MAIN folder:
    - includes folder (php includes)
    - images folder
    - js folder (javascript)
    - CSS folder

    i found a java script online to randomly choose an image whenever page is refreshed for example.
    and i had already made an include called header.php
    then where do i put the javascript? in the header.php since i am using it in all pages (although i dunno how)
    or do i put it in index.php and delete the part where i ask through php to include header.php?

    thanks in advance.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    West Springfield, Massachusetts
    198 Post(s)
    3 Thread(s)
    If your pages have
    PHP Code:
    include 'includes/header.php'
    and header.php contains the stuff between the <head> tags, then add to the the script tag mark-up in it like
    HTML Code:
    <script type='text/javascript' src='whatever.js' />
    if the script runs before the page loads in. Otherwise add an onload event handler to call the function, or include() it in your "footer.php" before the closing body tag.


Posting Permissions

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