Javascript 为什么我的“时事通讯注册”表单在模态对话框窗口中跳跃?

Javascript 为什么我的“时事通讯注册”表单在模态对话框窗口中跳跃?,javascript,jquery,html,css,modal-dialog,Javascript,Jquery,Html,Css,Modal Dialog,我有一个模式窗口,显示在主页上的每个页面加载上,稍后将进行修改,但窗口内的“电子邮件注册”表单加载方式存在问题 表单将随机出现在站点顶部一秒钟,然后跳入模式窗口,跳转到它应该在的位置,这显然不是我想要它做的。我希望它能像在任何时候一样加载到模态内部 以下是模式的设置: 以下是模式的代码/插件/脚本: 问题就在这里: 我认为这与CSS的加载/加载顺序有关 通过添加“绝对”位置,我可以在某种程度上复制这个问题 我的建议是将CSS文件的“position:relative”放在CSS文件的最开头,就

我有一个模式窗口,显示在主页上的每个页面加载上,稍后将进行修改,但窗口内的“电子邮件注册”表单加载方式存在问题

表单将随机出现在站点顶部一秒钟,然后跳入模式窗口,跳转到它应该在的位置,这显然不是我想要它做的。我希望它能像在任何时候一样加载到模态内部

以下是模式的设置:

以下是模式的代码/插件/脚本:

问题就在这里:
我认为这与CSS的加载/加载顺序有关

通过添加“绝对”位置,我可以在某种程度上复制这个问题

我的建议是将CSS文件的“position:relative”放在CSS文件的最开头,就像它放在末尾一样。这可能会在某种程度上解决这个问题

这实际上不会使它加载到弹出窗口中,但它“应该”几乎是即时的


至于如何正确加载,为什么不将整个弹出窗口设置为包含表单的iFrame。

您的表单iFrame将此设置作为其onload函数:

window.parent.scrollTo(0,0)

这可能就是导致跳转的原因。

将CSS的那一行拖到了底部,但它没有起作用。奇怪的是,在我在homeModal中添加顶部150px之前,就开始出现跳跃。当顶部达到50像素时,它不会跳。不,确保你把它带到顶部,而不是底部!除非你最初写错了,否则我只是把homeModal的顶部设置为50px,这是它最初设置的方式,它不会跳转。但是我想在Moonfall标志下面放一个模型,所以我不能把它放在那里。如果我想把homeModal的顶部设置为150px,我该怎么做呢?把它完全去掉就行了。该代码告诉您的页面在加载表单后立即滚动到顶部。删除了起始位置,但它仍在跳转。当homeModal的顶部设置为50px时,它不会跳转。你能想到什么吗?
 #homeModal {
    top: 150px;
    width: 450px;
    height: 400px;
    {% if image_width == blank %}
        max-width: 600px;
    {% else %}
        max-width: {{image_width}}px;
    {% endif %}
    right:0;
    left: 0;
    margin:auto;
    display:inline-block;
    padding: 0;
}



#homeModal img {
    width: 100%;
}
#homeModal iframe {
    position: relative;
    top: -193px;
    left: 25px;
}
 /*#homeModal iframe body,
  #homeModal iframe html
  {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
 } */

 @media screen and (max-width: 500px) 
 {
 #homeModal {
 height: 300px;
 width: 350px;
 min-width: 350px;
 }  
 #homeModal iframe {
 left: 1px;
 position: relative;
 top: -163px;
 }
 }
  <link rel="stylesheet" href="http://googledrive.com/host/0B51UCH0yGk6FVkFBakNmUXVuREk/reveal.css">
  <script src="http://googledrive.com/host/0B51UCH0yGk6FVkFBakNmUXVuREk/jquery.reveal.js" type="text/javascript"></script>    
  <script src="http://googledrive.com/host/0B51UCH0yGk6FVkFBakNmUXVuREk/jquery.cookie.js" type="text/javascript"></script>    
  <script>
  $(document).ready(function(){
  $('#homeModal img').attr('src', '{{popup_image}}');

  {% if show_on_first_visit_only == 'true' %}
  if (!$.cookie("popup")) {
    //trigger your popup message
    $('#homeModal').reveal({
        animation: 'none',                         //fade, fadeAndPop, none
        animationspeed: 300,                       //how fast animtions are
        closeonbackgroundclick: true,              //if you click background will modal close?
        dismissmodalclass: 'close-reveal-modal' 
    });       

    //after pop-up show, rewrite the cookie
    $.cookie("popup","false", {expires: 1} ); //not to show again
}
{% else %}
    $('#homeModal').reveal({
        animation: 'none',                         //fade, fadeAndPop, none
        animationspeed: 300,                       //how fast animtions are
        closeonbackgroundclick: true,              //if you click background will modal close?
        dismissmodalclass: 'close-reveal-modal' 
    });       
{% endif %}

  });
  </script>
window.parent.scrollTo(0,0)