[newbie] How to make simple JavaScript widget

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yi

    [newbie] How to make simple JavaScript widget

    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!
  • Evertjan.

    #2
    Re: [newbie] How to make simple JavaScript widget

    Yi wrote on 10 jul 2008 in comp.lang.javas cript:
    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)

    Comment

    • Hamish Campbell

      #3
      Re: How to make simple JavaScript widget

      On Jul 10, 11:19 pm, "Evertjan." <exjxw.hannivo. ..@interxnl.net >
      wrote:
      Yi wrote on 10 jul 2008 in comp.lang.javas cript:
      >
      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="javas cript" src="http://ajax.googleapis .com/ajax/
      libs/jquery/1.2.6/jquery.min.js"> </script>
      <script language="javas cript" type="text/javascript">$
      (document).read y(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

      Comment

      Working...