我有以下代码
<div class="AW-Form-2026756516"></div>
<script type="text/javascript">
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "http://forms.aweber.com/form/16/2026756516.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "aweber-wjs-ielieh3he"));
</script>
它显示了一个灯箱订阅表单。
但是我想在用户点击按钮后显示,而不是自动显示。
<div id="subscribe"><a href="">Subscribe</a></div>
非常感谢你的帮助。
答案 0 :(得分:1)
Use onclick event
<div class="AW-Form-2026756516">
</div>
<script type="text/javascript">
function ShowSubscribe(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "http://forms.aweber.com/form/16/2026756516.js';
fjs.parentNode.insertBefore(js, fjs);
}
</script>
<div id="subscribe">
<a href="#" onclick="ShowSubscribe(document, 'script', 'aweber-wjs-ielieh3he');">Subscribe</a></div>
答案 1 :(得分:0)
因为您使用按钮来触发事件。试试这个。
<div class="AW-Form-2026756516"></div>
<script type="text/javascript">
function ShowSubscribe()
{
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "http://forms.aweber.com/form/16/2026756516.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "aweber-wjs-ielieh3he"));
}
</script>
<div id="subscribe">
<button onclick="ShowSubscribe()">Click me</button>
</div>
答案 2 :(得分:-1)
<div class="AW-Form-2026756516"></div>
<script type="text/javascript">
function ShowSubscribe()
{
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "http://forms.aweber.com/form/16/2026756516.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "aweber-wjs-ielieh3he"));
}
</script>
<div id="subscribe">
<a href="javascript:ShowSubscribe()">Subscribe</a>
</div>