By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,630 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,630 IT Pros & Developers. It's quick & easy.

[newbie] How to make simple JavaScript widget

P: n/a
Yi
I want to make a simple javascript widget, something looks like the
Google AdWords, that people can just post a small section of code on
their web page and display some content from my website.

I searched online and found many javascript tools and packages but all
seem to be building widgets for a widget platform. I want something
that anybody can just copy and paste on their web page no matter they
are using ASP.NET or html or PHP for the pages.

ideas? pointers?

Thanks!
Jul 10 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Yi wrote on 10 jul 2008 in comp.lang.javascript:
I want to make a simple javascript widget, something looks like the
Google AdWords, that people can just post a small section of code on
their web page and display some content from my website.
You cannot "post" code on a website, you will have to insert it in the
sourcecode.
I searched online and found many javascript tools and packages but all
seem to be building widgets for a widget platform. I want something
that anybody can just copy and paste on their web page no matter they
are using ASP.NET or html or PHP for the pages.
HTML is clientside and quite capable of inserting an iframe,
no need for clientside javascript.

Serverside insertion would be much nicer, ASP, ASP.net and PHP run
serverside, ASP has serverside javascript, perhaps you mean that?

Better learn some javascript, Yi, it will come usefull not only to
programme, but also to understand wat you were asking here.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 10 '08 #2

P: n/a
On Jul 10, 11:19*pm, "Evertjan." <exjxw.hannivo...@interxnl.net>
wrote:
Yi wrote on 10 jul 2008 in comp.lang.javascript:
I want to make a simple javascript widget, something looks like the
Google AdWords, that people can just post a small section of code on
their web page and display some content from my website.

You cannot "post" code on a website, you will have to insert it in the
sourcecode.
I searched online and found many javascript tools and packages but all
seem to be building widgets for a widget platform. I want something
that anybody can just copy and paste on their web page no matter they
are using ASP.NET or html or PHP for the pages.

HTML is clientside and quite capable of inserting an iframe,
no need for clientside javascript.

Serverside insertion would be much nicer, ASP, ASP.net and PHP run
serverside, ASP has serverside javascript, perhaps you mean that?

Better learn some javascript, Yi, it will come usefull not only to
programme, but also to understand wat you were asking here.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
A lot of platforms provide access to a templating engine, but not the
source itself.

Here is a complete, working solution in 3 lines:

Put this in the head of the page:

<script language="javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.2.6/jquery.min.js"></script>
<script language="javascript" type="text/javascript">$
(document).ready(function(){$.getScript("http://MyDomain/
MyScript.js")});</script>

This loads the jQuery library (jquery.com). Once the DOM is ready it
loads and executes a remote script located at http://MyDomain/MyScript.js.
Now you have all the jQuery functionality at your fingertips.

If we assume that the user has placed a div with the id "MyWidget", we
could do the following (for example):

[in MyScript.js]:
$('#MyWidget').html('Hey, check out this great new widget');

Personally, I think you'd be crazy to allow random code execution to
happen on your website, but that's up to your users.

Cheers,
Hamish
Jul 12 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.