Skip to content

Instantly share code, notes, and snippets.

@lukebaker
Created March 29, 2011 13:52
Show Gist options
  • Save lukebaker/892396 to your computer and use it in GitHub Desktop.
Save lukebaker/892396 to your computer and use it in GitHub Desktop.
Dynamically insert widget with info code.
<div id="ideamarketplace"></div>
<script>
(function(appendTo, info) {
var el = document.createElement("iframe");
el.src = 'http://widget.allourideas.org/testmarketplace?info='+info+'&submit_button=FCC044&vote_button=FCC044&flag_text=000000&tab_hover=000000&cant_decide_button=FCC044&add_idea_button=FF7600&question_text=000000&text_on_color=000000';
el.width = '815';
el.height = '400';
el.frameborder = '0';
el.scrolling = 'no';
document.getElementById(appendTo).appendChild(el);
})('ideamarketplace', 'info_id');
</script>
@msalganik
Copy link

Documentation:

  • Line 1 is HTML element that the widget will be inserted into.
  • Next is a self-contained JavaScript function that gets called immediately. On line 11 we're passing the function the strings, 'ideamarketplace' and 'info_id'. 'ideamarketplace' is the id of the HTML element that we're inserting the widget into which matches the ID on line 1. info_id is whatever value they want to show up in the CSV report. Maybe they change that for different widgets, or maybe the page itself has a value that they'd want to pass into the info field.
  • Line 5 has widget attributes (colors, etc.) that may be modified.
  • Lines 6 and 7 may be modified to suit the user.

@an
Copy link

an commented Dec 3, 2011

Is this for google gadgets?

@allourideas
Copy link

No, this is not for Google Gadgets. Here's more information about the allourideas widget: http://blog.allourideas.org/post/912665189/improved-widget-gives-you-more-control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment