我需要将以下 HTML 片段附加到文档中,用一个值替换 display_spinner 参数:
<script type="text/javascript" src="http://public.tableausoftware.com/javascripts/api/viz_v1.js"></script>
<div class="tableauPlaceholder" id="tableauPlaceholder" style="visibility:hidden;width:654px; height:1469px;background-image: url('http://tableau.russellchristopher.org:81/Background.gif'); top: 0px; left: 0px; width: 100%; margin-left: 76px;">
<noscript>
<a href="#"><img alt="Analytics, Inc. "
src="http://tableau.russellchristopher.org:81/Background.gif"
style="border: none" /></a>
</noscript>
<object class="tableauViz" width="654" height="1469" style="display:none;">
<param name="host_url" value="http%3A%2F%2Fpublic.tableausoftware.com%2F"
/>
<param name="site_root" value="" />
<param name="name" value="AnalyticsIncJavaScript/AnalyticsInc" />
<param name="tabs" value="no" />
<param name="toolbar" value="yes" />
<param name="static_image" value="tableau.russellchristopher.org:81/Background.gif"
/>
<param name="animate_transition" value="yes" />
<param name="display_static_image" value="yes" />
<param name="display_spinner" value="" id="display_spinner" />
<param name="display_overlay" value="yes" />
<param name="display_count" value="yes" />
</object>
</div>
这是我想出的(这里的JSFiddle:http: //jsfiddle.net/9vBGq/)
$(document).ready(function () {
var $placeholder = $('<div class="tableauPlaceholder" style="width:654px; height:1469px;background-image: url("http%3A%2F%2Ftableau.russellchristopher.org:81%2FBackground.gif"); top: 0px; left: 0px; width: 100%; margin-left: 76px;"></div>'),
$noscript = $('<noscript> <a href="#"><img alt="Analytics, Inc. " src="http%3A%2F%2Ftableau.russellchristopher.org:81/Background.gif" style="border: none" /></a></noscript>'),
$tableauViz = $('<object class="tableauViz" width="654" height="1469"></object>'),
$host_url = $('<param name="host_url" value="http%3A%2F%2Fpublic.tableausoftware.com%2F">'),
$site_root = $('<param name="site_root" value="" />'),
$sheetName = $('<param name="name" value="AnalyticsIncJavaScript/AnalyticsInc" />'),
$tabs = $('<param name="tabs" value="no" />'),
$toolbar = $('<param name="toolbar" value="yes" />'),
$static_image = $('<param name="static_image" value="http://tableau.russellchristopher.org:81/Background.gif"/>'),
$animate_trasnsition = $('<param name="animate_transition" value="yes" />'),
$display_static_image = $('<param name="display_static_image" value="yes" />'),
$display_overlay = $('<param name="display_overlay" value="yes" />'),
$display_count = $('<param name="display_count" value="yes" />'),
$display_spinner = $('<param name="display_spinner" value="' + 'no' + '" />');
$placeholder.append($noscript).append($tableauViz).append($host_url).append($site_root).append($sheetName).append($tabs).append($toolbar).append($static_image).append($animate_trasnsition).append($display_static_image).append($display_overlay).append($display_count).append($display_spinner).appendTo('body');
console.log(document.body);
});
从我在 console.log 中看到的内容来看,存在多个问题 - 我对这些东西还太陌生,无法确切知道原因:
- 我的 URL 编码
<div>
看起来很糟糕。我做错什么了? <a>
嵌套在 noscript 块内的标签看起来很糟糕</object>
在我列出我的参数后它应该关闭时有一个结束标签- 关闭
/>
每个我的参数都丢失了——我假设 URL 编码又是奇怪的,但不确定如何处理。
我怀疑你是专业人士,并在几秒钟内将我踢向正确的方向......请在你认为合适的时候踢我?谢谢。