SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Location
    india
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    want to call the <script> from outside

    i want to split the code in the file, and want to call the javascript from outside this file. if its possible, please help me out in this, i have attached the file with this thread. thanx in advance.
    Last edited by krishkam; Nov 18, 2008 at 15:51.

  2. #2
    SitePoint Zealot smadeira's Avatar
    Join Date
    Oct 2003
    Location
    Pennsylvania
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Couldn't you put all of the javascript code in a .php file and then do an include in your main code page?
    Scott

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Location
    india
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx for your reply, i would like to tell you that i am doing already what your are suggesting, but i want to split the code furthermore so that to hide it in the source code of the website.

  4. #4
    SitePoint Zealot smadeira's Avatar
    Join Date
    Oct 2003
    Location
    Pennsylvania
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because you are basically dynamically building the JavaScript each time the application runs the only thing I can think of would be to have your php code build the JavaScript in a .js file and then in the php / HTML reference that JavaScript file.

    There are a number of issues with this approach:

    1. You would need to include a session identifier in the .js file name to ensure you send the correct file to the correct browser.
    2. You would need a way to do cleanup on the .js files periodically
    3. Performance may suffer because you are generating a text file every time the script is run.


    There may be some fancy JavaScript things you could do like passing in parameters instead of calculating them each time to eliminate the <?php .... ?> stuff from within your JavaScript.

    I'd look at how you can best get rid of the php code from within the javascript code. that doesn't seem like a good coding practice to me.
    Scott


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
  •