我是博客,我正在尝试在我的网站上传小部件,我已经从here
获取了小部件的代码据我所知,我只需要在HTML中复制/粘贴代码。可悲的是,它不会这样工作。
我觉得它与我网站上的一些代码有冲突,所以我在一个空的HTML文件中对它进行了测试,但它再次无法正常工作。
我把代码放在一个片段中,我希望有人可以看一下,所以我知道问题出在哪里。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>momondo flight widget</title>
</head>
<body>
<div id="mmd-flight-widget"></div>
<script type="text/javascript">(function initWidget() {
var options = {
layout: {
theme: "momondo"
, width: "300"
, height: "250"
},
airports: {
origin: "LON",
destination: "PAR"
},
settings: {
openNewWindow: true,
domain: "www.momondo.com",
source: ""
}
};
var settings = options.settings;
var airports = options.airports;
var layout = options.layout;
var encoding = null;
onWidgetLoad = function (f)
{
f("mmd-flight-widget", {
searchForms: [{
type: 1,
searchURL: "http://[DOMAIN][PATH][QUERY]" + (!!settings.source ? "&source=" + settings.source : ""),
openNewWindow: settings.openNewWindow,
currency: settings.currency,
segments: [
{
airports: [
{ code: airports.origin || "" },
{ code: airports.destination || "" }
]
},
{
airports: [
{ code: airports.destination || "" },
{ code: airports.origin || "" }
]
}
]
}]
});
};
var scr = document.createElement("script");
scr["src"] = "http://" + settings.domain + "/widget/searchform/v1.0/?dimensions=" + (layout.width && layout.height ? (layout.width + "x" + layout.height) : "generic") + "&types=1&callback=onWidgetLoad&theme=" + layout.theme;
var tag = document.getElementsByTagName("head");
if (tag && tag.length)
{
tag = tag[0];
tag.appendChild(scr);
}
})();
</script>
</body>
</html>
&#13;
答案 0 :(得分:0)