Results 1 to 8 of 8

Thread: .js files (CSS made me think of this question)

  1. #1
    Join Date
    Jul 2007
    Location
    California
    Posts
    177
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default .js files (CSS made me think of this question)

    I'm brand new to this, so forgive me if this is a daffy question.

    I've learned how CSS can apply many things to many pages from one file. I recently noticed a .js javascript file in my directory from a menu tabs I downloaded from here. It told me to put it in the directory so I did.

    I was wondering if this .js file can contain everything to do with the script, ie the list it needs, as well as links and labels within the list? This way I could just simply imbed it in a div and place it in every page.

    The reason I'm asking this, is that it would allow me to update every link and target on the menu without having to do this page by page.

    Any thoughts?

    Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's a bad idea, since the menu links will be unavailable to non-JS users.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2007
    Location
    California
    Posts
    177
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Ahh that makes sense... well with that in mind, I suppose once I get the nav bar dropping down in the wrong place fixed... I should create pages for each of the top 9 main links that takes them to a menu page so they can access the list of links as well? Or will the whole list show up without JS on?

    Thanks

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Depends on the script. The former is the accepted solution if they don't, though.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The better idea here would be to use PHP or another form of server side inclusion. It can do the exact same thing, but will work for all browsers/users.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jul 2007
    Location
    California
    Posts
    177
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Ack you didn't just say PHP did you? I just spent the week buried in turorials on HTML and CSS and was starting to see the light!!!!

    Anyone know where a good PHP tutorial is? Oh, and anyone know what PHP is?

    Thanks,

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    PHP is very simple, in its most basic uses. And the include function is one of those. It will be very daunting at first, but just because you're not used to it. There's nothing very complex about its use.

    <?php include('file.ext'); ?> Will include (take the contents of) a file, and output that data exactly where that tag is, like <div><?php ... ?></div> would fill the div with the data of a file.

    The page MUST end in .php, and your server must have PHP installed/enabled.

    And that's it.

    It won't change how anything on your page functions.

    You will also not see it in the source code as PHP is executed before the page it sent, then outputting plain text, just as if you have cut and paste the contents of the included file yourself.
    Last edited by Twey; 07-16-2007 at 01:34 PM. Reason: Minor grammar correction (its/it's). It was bugging me.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    There's nothing very complex about [the] use [of PHP].
    That's not strictly true: anyone using PHP or some other server-side language should understand the HTTP protocol properly. Not doing so can adversely affect interactions with the server. These effects can be the relatively minor, such as wasted bandwidth, to the major: rejected communication.

    Just because PHP as a language is simple - too simple, in my opinion - doesn't mean that using it is necessarily the same.
    Last edited by mwinter; 07-16-2007 at 05:37 PM. Reason: Missing word
    Mike

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
  •