Including other javascript
Hi :wave:
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 :wave:
Re: Including other javascript
Found a good tutorial: http://www.quarkruby.com/2008/1/7/widget :)
html Code:
<script type="text/javascript">
unique_key_each_host = "blah_123";
// some other variables ..
</script>
<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 ? :confused:
:wave:
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:
<script type="text/javascript"
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 ?:confused:
Will that conflict ? If so, how do I overcome it ? :confused:
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
}
Re: Including other javascript
Quote:
Originally Posted by
SambaNeko
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 ? :confused:
Quote:
Originally Posted by
SambaNeko
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 :wave: