Results 1 to 5 of 5

Thread: Including other javascript

  1. #1

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Question Including other javascript

    Hi

    I'm trying to create a small widget for some of my friends's blogs.
    The idea is, I'll give them a JavaScript code to them and they will paste that code in their blog(like Adsense). So, when rendered(ie. when some view that blog), they will see an image. Which upon clicked will popup a screen like in LightBox and will display some content inside it. The content will be generated dynamically. Means, a PHP page will be queried(which will be residing in my server) and the output of the query will be displayed in the LightBox kind of way.

    Please enlighten me by providing some details on how to do this or solutions or where to start.

    Thanks

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  2. #2

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Including other javascript

    Found a good tutorial: http://www.quarkruby.com/2008/1/7/widget

    html Code:
    1. <script type="text/javascript">
    2.   unique_key_each_host = "blah_123";
    3.   // some other variables ..
    4. </script>
    5. <script src="http://www.mysite.com/blah/blah-blah-blah.js"></script>
    So, I could simply do a document.write to display a image with link. My question is, when this link is clicked, it would popup a LightBox kind of box. So, inorder to work, it needs the j-query core. How would I include it in the client side without making a collision on the various versions ?


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Including other javascript

    Ok.. I have found that Google hosts that jquery in GoogleAPIs : http://encosia.com/3-reasons-why-you...query-for-you/
    So, I have to just document.write:
    html Code:
    1. <script type="text/javascript"
    2.  src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    But what happens if the user had already included that jquery.js in that webpage ?

    Will that conflict ? If so, how do I overcome it ?

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  4. #4
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Including other javascript

    Ideally you shouldn't insert a third party library into someone's page; using a plain Javascript solution will give you better control over containing the scope of your script, and should be a lighter footprint on page load times.

    But, if you're going with jQuery... you could include it conditionally...
    Code:
    if(typeof(jQuery) == "undefined"){
      //include jquery library code
    }

  5. #5

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Including other javascript

    Quote Originally Posted by SambaNeko View Post
    using a plain Javascript solution will give you better control over containing the scope of your script, and should be a lighter footprint on page load times.
    You mean I should try not to use third party APIs like jQuery ?

    Quote Originally Posted by SambaNeko View Post
    But, if you're going with jQuery... you could include it conditionally...
    Code:
    if(typeof(jQuery) == "undefined"){
      //include jquery library code
    }
    So, document.write ? Or is there any other function like include() in PHP ?

    Thanks

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

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



Click Here to Expand Forum to Full Width