如何将标签链接到onload模式窗口?

时间:2014-02-04 19:37:19

标签: javascript jquery html css html5

我想出了如何在页面加载时弹出模态窗口,但我想知道如何在点击链接后使其显示,这样如果第一次用户访问网站,则关闭onload模态窗口,然后想要注册,他可以这样做。

我从以下代码获得了代码:http://www.aspdotnet-suresh.com/2013/03/open-show-jquery-popup-window-on-page.html

我正在使用它的网站是http://thewildernesswalk.businesscatalyst.com/

如果你有一个比我发现的教程更好的解决方案(这将是很棒的),我很满意,但似乎有些其他答案我发现那些混乱的代码使导航棒坚持顶部和“返回顶部”按钮出现。

提前谢谢

1 个答案:

答案 0 :(得分:0)

假设您提供的链接上的代码,您可以在HTML <body>中插入以下内容,以便在点击超链接时显示模式:

<a href="" id="hyper">Click me!</a>
<script>
var elem = document.getElementById('hyper');
elem.onclick = showModal;

function showModal() {
    $('.popup').show();
    return false;
}
</script>