Results 1 to 3 of 3

Thread: how do i insert a javascript in the body of a web page made in php

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

    Default how do i insert a javascript in the body of a web page made in php

    how do i insert a javascript in the body (not head) of a web page made in php:

    earlier i had the same page done in html where i could insert the thumbnail script in the head of the document
    Now the site is being done in php & i have been told i can only put the ( java script in the body of the webpage and not the head , so how can i do that?

    please help!

  2. #2
    Join Date
    Apr 2008
    Thanked 516 Times in 502 Posts
    Blog Entries


    Your question is unclear.
    Please provide more information, and be as specific as possible.
    • What do you want to accomplish?
    • What have you already tried?
    • What problems did you encounter?

    Also, please be sure that you have included all relevant code and/or a link to the page in question.

    PHP writes javascript the same way it writes html.
    PHP Code:
    Your question, however, is very vague.

    Is this a script you are writing? You need to learn more about PHP.

    Is this a script someone else wrote? Ask them how to integrate your javascript.

    Is this a CMS (like Wordpress or Joomla)? You need to learn about how that CMS works (and probably more about PHP in general as well).

    I'm sorry I can't offer anything more constructive, but you haven't really asked a question here - you've just stated that you don't know how to do something, without offering any context or clue as to your goals or specific problem.

    If you're looking for someone to do this for you, you should post in the Paid Work forum.

  3. #3
    Join Date
    Mar 2006
    Illinois, USA
    Thanked 690 Times in 678 Posts


    As a very general response, it is possible to put Javascript (<script> tags) anywhere on your page that you'd like. Sometimes it's better to put them lower (in the body section) so that they load after the rest of the page loads. That can make the page appear to load faster. It's not require that anything goes in the head, but it DOES change the order of things. So sometimes you will need a script in the head section so that it sets up something correctly later on the page or you might experience a delay or a broken script because it wasn't set up in the correct order.

    It's easy to test this: just add the content in the body section. (Near the topic is probably safest, but that's not an absolute rule.) And if that works, great. If not, you will need to find out how to edit the head section. Many CMS setups make this difficult, but if you're creating it yourself you can usually find a (complicated) way around it. If not, you may need to ask the creators, OR you might just need to change systems-- if it doesn't do everything you need, you might need a new system.

    I don't know about this script in particular, whether it requires that the code is in the head section or not. But again, that's something you can test.
    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

  4. The Following User Says Thank You to djr33 For This Useful Post:

    asiatic (11-15-2011)


Posting Permissions

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