简体   繁体   中英

newbie question about javascript embed code?

I am a javascript newbie. I am trying to write a requirements document, and need some help describing what I am looking for. We want our application to generate a javascript snippet like this:

<script src="http://www.jotform.com/jsform/10511502633"></script> 

This will load a web form.

So my question is: - How does a single script load an entire web form? Is this a JSON? - What is this called? Is this a cross browser javascript? - Can anyone point me in the direction of learning more about what this is?

Thank you for your help!

The javascript file is just hosted on an external site . It appears to be dynamically generated, so feel free to use some fancy words ;) But basically, you just include it here, as if it was on your own site.

You could say " The application will generate the required script-tags to include dynamically generated javascript file from an external, third-party site ".

Offcourse you need to take special cautions for cases when the include won't work, because the other site is not reachable (site is down, DNS does not work, file is moved on other webserver, your application is on an intranet/behind a proxy/firewall...). Why can't you copy their file and mirror it locally ? Or use a reliable Content Delivery Network, like Google or Amazon.

There are many names for this type of inclusion. The most common being widget .
What does it actually do:

  • take an id of some sort as parameter
  • use the id to fetch some specific data (most likely from a database)
  • generate some js and html based on the id/data
  • usually this involves iframes of some sort.

To use a script rather than an html iframe has multiple advantages

  • you can change what is actually delivered to the users browsers without changing the include
  • you can resize the iframe to fit certain predefined sizes
  • you can inject the necessary things into the page the widget is included (of course you need to make sure this is sanctioned)

We use this all the time and we never regreted it.

If you don't want to build the widget infrastructure yourself you can always use one of the widget providers like widgetbox: http://www.widgetbox.com/widgets/make/

With those you are up and running in no time.

这通常称为脚本包含。

Google have lots of these types of items, and even they call them by many names, widgets, custom javascript, snippets, custom code, etc. It really depending on who you are writing for... I would go with "cross platform embeddable javascript code" meaning that it would need to load all its dependancies. Also specify which browsers need to be supported and what should happen is the user has javascript turned off.

EDIT :

Actually since we are talking unique IDs, you will need 2 parts probably, the user/site unique "cross platform embeddable javascript code" and whatever serverside code to support it. Basically this is an API that is accessed using your own javascript widget. Feel free you point to examples in your requirements document, programmers love examples.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM