0

我正在尝试更改我的 index.html 以在我的站点的引用者 == 时显示模式窗口(例如,如果它们来自 Google,则显示一个“欢迎 Googler”对话框,其中包含一个图像)。

我正在使用 FancyBox,但我还没有结婚。

关于如何编码的任何建议?我是一名 C++ 程序员——Javascript 不是我的强项,所以非常感谢直接的例子。

提前致谢。

4

1 回答 1

3

您将需要一些东西:document.referrer 和 jQuery UI。jQuery UI 使对话框变得非常简单。

您可以从文档页面找到一个深入的示例,但在大多数情况下,这就是您需要的:

<script type="javascript/text">
    if (document.referrer.indexOf('google.com') > -1){
        $("#my-dialog").dialog("open");
    }

    // this is the jquery code to set up the dialog box
    $(function() {
            // options would go inside the dialog() function
    $("#dialog").dialog();
});

</script>

所需的 HTML:

<div id="my-dialog">
This is where things get displayed
</div>
于 2009-07-20T13:39:15.507 回答