是否有可能以编程方式添加亚马逊MP3的小部件 [英] Is it possible to programmatically add Amazon MP3 widgets
问题描述
我试图建立使用Amazon MP3的小部件发挥每个结果的音乐搜索。相反,建立一个完整的,这些小部件的页面,我想用户点击的专辑封面,然后小部件将加载。
I'm trying to build a music search using Amazon mp3 widgets to play each result. Instead of building a page full of these widgets, I'd like the user to click the album art and then the widget would load.
在code,我有如下:
The code that I have looks like this:
function loadPlayer(asin) {
var amzn_wdgt={widget:'MP3Clips'};
amzn_wdgt.tag='widgetsamazon-20';
amzn_wdgt.widgetType='ASINList';
amzn_wdgt.ASIN=asin;
amzn_wdgt.title='What I\'ve been listening to lately...';
amzn_wdgt.width='250';
amzn_wdgt.height='250';
amzn_wdgt.shuffleTracks='True';
amzn_wdgt.marketPlace='US';
}
在他们的文档( https://widgets.amazon.com/Widget-Source/),他们有一个脚本加载的插件:
In their documentation (https://widgets.amazon.com/Widget-Source/), they have a script to load the widget:
<script type='text/javascript' src='http://wms.assoc-amazon.com/20070822/US/js/swfobject_1_5.js'></script>
这是我遇到的问题是,我似乎无法找到一个方法来动态加载脚本。该脚本加载插件到包含code中的元素,所以我不knw如何使用jQuery或javascript做到这一点。任何帮助将是AP preciated。
The issue that I'm running into is that I can't seem to find a way to load that script dynamically. The script loads the widget into the element that contains the code, so I don't knw how to do this with jQuery or javascript. Any help would be appreciated.
推荐答案
查看jQuery的 getScript加入
: http://api.jquery.com/jQuery.getScript/
Check out jquery's getScript
: http://api.jquery.com/jQuery.getScript/
更新要在下面回答你的问题,脚本需要一个全局变量,所以你需要更多的东西,如:
Update To answer your question below, the script expects a global variable, so you'll need something more like:
var amzn_wdgt;
function loadPlayer(asin) {
amzn_wdgt={widget:'MP3Clips'};
amzn_wdgt.tag='widgetsamazon-20';
...yada yada...
$.getScript(...)
}
这篇关于是否有可能以编程方式添加亚马逊MP3的小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!