Results 1 to 4 of 4

Thread: javascript command help

  1. #1
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default javascript command help

    is there a javascript command that is the same as <?php include (page); ?>? I'm writing a page using javascript and the page is getting too long. I'd like to have it pull in other sources.


    Also my site is built like so:

    function projects() {
    document.getElementById("content").innerJS = "<h1>Past Projects</h1><br><h2>yesterday's work...</h2>
    <script type="text/javascript">

    //Define your own array to hold the photo album images
    //Syntax: ["path_to_thumbnail", "opt_image_title", "opt_destinationurl", "opt_linktarget"]

    var myvacation=new Array()
    myvacation[0]=["../photo1.jpg", "", "photo1-large.jpg"]
    myvacation[1]=["photo2.jpg", "Our car", ""]
    myvacation[2]=["photo3.jpg", "Our dog", "photo3-large.jpg"]
    myvacation[3]=["photo4.jpg", "Our hotel", "http://www.gohawaii.com/"]

    //initiate a photo gallery
    //Syntax: new photogallery(imagearray, cols, rows, tablewidth, tableheight, opt_[paginatetext_prefix, paginatetext_linkprefix])
    var thepics=new photogallery(myvacation, 3, 1, '700px', '600px') </script>";
    }
    function contact() {
    document.getElementById("content").innerHTML = "<h1>Contact</h1><br><h2>my 411...</h2>";
    }
    </script>
    When I put javascript inside the element it destroys the rest of the code. How can I fix that?

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    you can link a js file into a html page, however I do not think that there is a method that does the equivalent of a PHP include/require.

    you could seperate the code into a seperate function, then when you wanted to call it, just initiate the function

  3. #3
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Welll...

    To include Javascipt files use
    Code:
    <Script src="(js_file)" type="text/javascript" language="javascript"></script>
    just write pure javascript in these files.

    As for you code, it needs to be cleaned up a little.


  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Bob90 View Post
    To include Javascipt files use
    Code:
    <Script src="(js_file)" type="text/javascript" language="javascript"></script>
    just write pure javascript in these files.
    The current standard is:

    Code:
    <script src="filename.js" type="text/javascript"></script>
    Language has been deprecated and will not validate.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •