Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从单独的页面触发打开jQuery UI对话框?_Jquery_Jquery Ui_Dialog - Fatal编程技术网

如何从单独的页面触发打开jQuery UI对话框?

如何从单独的页面触发打开jQuery UI对话框?,jquery,jquery-ui,dialog,Jquery,Jquery Ui,Dialog,我对jQuery不是很在行,最近遇到了麻烦。我有一个jQueryUI对话框,当用户在index.html上触发它时,它就会打开。它隐藏在index.html上,直到用户触发它打开。在另一个单独的html页面上,我有一个按钮将您链接回index.html,但我需要做的是,当用户单击此链接时,它会将他们带回index.html,并触发对话框模式窗口自动打开 在某种程度上,我可以使用它,但我想找到一个替代解决方案,在这个解决方案中,我不使用URL使它工作 “返回”链接的HTML 将弹出UI的jQuer

我对jQuery不是很在行,最近遇到了麻烦。我有一个jQueryUI对话框,当用户在index.html上触发它时,它就会打开。它隐藏在index.html上,直到用户触发它打开。在另一个单独的html页面上,我有一个按钮将您链接回index.html,但我需要做的是,当用户单击此链接时,它会将他们带回index.html,并触发对话框模式窗口自动打开

在某种程度上,我可以使用它,但我想找到一个替代解决方案,在这个解决方案中,我不使用URL使它工作

“返回”链接的HTML

将弹出UI的jQuery:

$( ".dialog-popup" ).dialog({
  autoOpen: false,
  modal: true,
  width: 860,
  show: {
    effect: "fade",
    duration: 500
  },
  hide: {
    effect: "fade",
    duration: 500
  }
});

这里的任何帮助都将不胜感激。我希望它能够工作,而不必将#对话框放在URL中

您可以使用
document.referer
来确定用户的来源。如果您解析document.referer以获取有关用户来自的页面的信息,并将其与某些内容进行匹配,则可以通过这种方式触发对话框

例如,如果希望在用户从域中的页面(而不是从index.html本身)到达index.html时触发该对话框,则可以运行以下代码:

jQuery(function($){

    var referrerDomain = document.referrer.replace(/(http|https):\/\//,'').split("/")[0];
    var myDomain = "mydomain.net"; //Your domain name goes here
    if( referrerDomain == myDomain && !document.referrer.match("index.html") )
        alert('You arrived at this page from your domain, but not from index.html!')

});
如中所示(全屏版)


注意-提琴将显示与您当前所在页面相同的推荐人。这不会发生在普通页面上;发生这种情况是因为它使用了iFrames。

你可以设置一个cookie,index.html可以检查这个cookie并打开对话框。我同意这一点,这可能是一个解决方案。我不知道如何写这篇文章,你能帮我吗?用更多信息编辑了我的文章
$( ".dialog-popup" ).dialog({
  autoOpen: false,
  modal: true,
  width: 860,
  show: {
    effect: "fade",
    duration: 500
  },
  hide: {
    effect: "fade",
    duration: 500
  }
});
jQuery(function($){

    var referrerDomain = document.referrer.replace(/(http|https):\/\//,'').split("/")[0];
    var myDomain = "mydomain.net"; //Your domain name goes here
    if( referrerDomain == myDomain && !document.referrer.match("index.html") )
        alert('You arrived at this page from your domain, but not from index.html!')

});