<i id='DaH0X'><tr id='DaH0X'><dt id='DaH0X'><q id='DaH0X'><span id='DaH0X'><b id='DaH0X'><form id='DaH0X'><ins id='DaH0X'></ins><ul id='DaH0X'></ul><sub id='DaH0X'></sub></form><legend id='DaH0X'></legend><bdo id='DaH0X'><pre id='DaH0X'><center id='DaH0X'></center></pre></bdo></b><th id='DaH0X'></th></span></q></dt></tr></i><div id='DaH0X'><tfoot id='DaH0X'></tfoot><dl id='DaH0X'><fieldset id='DaH0X'></fieldset></dl></div>

        <bdo id='DaH0X'></bdo><ul id='DaH0X'></ul>
      1. <tfoot id='DaH0X'></tfoot>

        <small id='DaH0X'></small><noframes id='DaH0X'>

      2. <legend id='DaH0X'><style id='DaH0X'><dir id='DaH0X'><q id='DaH0X'></q></dir></style></legend>

        当有人访问它时,如何在我的主页上自动弹出图像?

        How do I make an image automatically popup on my main page when someone goes to it?(当有人访问它时,如何在我的主页上自动弹出图像?)
          • <i id='FuJo4'><tr id='FuJo4'><dt id='FuJo4'><q id='FuJo4'><span id='FuJo4'><b id='FuJo4'><form id='FuJo4'><ins id='FuJo4'></ins><ul id='FuJo4'></ul><sub id='FuJo4'></sub></form><legend id='FuJo4'></legend><bdo id='FuJo4'><pre id='FuJo4'><center id='FuJo4'></center></pre></bdo></b><th id='FuJo4'></th></span></q></dt></tr></i><div id='FuJo4'><tfoot id='FuJo4'></tfoot><dl id='FuJo4'><fieldset id='FuJo4'></fieldset></dl></div>
            • <bdo id='FuJo4'></bdo><ul id='FuJo4'></ul>
              <legend id='FuJo4'><style id='FuJo4'><dir id='FuJo4'><q id='FuJo4'></q></dir></style></legend>

                  <tbody id='FuJo4'></tbody>

                  <tfoot id='FuJo4'></tfoot>

                  <small id='FuJo4'></small><noframes id='FuJo4'>

                  本文介绍了当有人访问它时,如何在我的主页上自动弹出图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我希望在有人访问我们的主页时自动弹出一张图片.他们可以在看到后单击以关闭它.有人可以告诉我如何在不需要大量编码的情况下做到这一点.谢谢你!

                  I want an image to automatically popup when someone goes to our main page. One that they can click to close after they have seen it. Can someone please show me how to do this that doesn't require a ton of coding. Thanks you!

                  推荐答案

                  我会用 jQuery 来做这件事(我打赌你也在用 jQuery 作为你的模板:))

                  I would do this with jQuery (and I bet you're using jQuery for your template too :) )

                  确保您在页面中调用了 jQuery 库,我建议将其放在 </body> 标记之前和所有脚本之下.

                  Be sure you're calling the jQuery library in your page, I would recommend to place it just before the </body> tag and BELOW all the scripts.

                  例如

                  <!doctype html>
                  <html lang="en">
                  <head>
                      <meta charset="UTF-8">
                      <title>Document</title>
                  </head>
                  <body>
                      <!-- let's call the following div as the POPUP FRAME -->
                  <div id="popup">
                  
                      <!-- and here comes the image -->
                      <img src="http://i.imgur.com/cVJrCHU.jpg" alt="popup">
                  
                          <!-- Now this is the button which closes the popup-->
                          <button id="close">Close button</button>
                  
                          <!-- and finally we close the POPUP FRAME-->
                          <!-- everything on it will show up within the popup so you can add more things not just an image -->
                  </div>
                  
                  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
                  
                  <script>
                  //your jquery script here
                  </script>
                  
                  </body>
                  </html>
                  

                  这会显示一段代码,如果你想简单地显示一个图像,把 id="popup" 直接放在你的 <img> 标签上.

                  This will show up a piece of code, if you want to simply show an image, put the id="popup" directly on your <img> tag.

                  现在,让我们转到示例...代码很容易理解:

                  Now, let's move to the example... the code is pretty easy to understand:

                  //with this first line we're saying: "when the page loads (document is ready) run the following script"
                  $(document).ready(function () {
                  
                      //select the POPUP FRAME and show it
                      $("#popup").hide().fadeIn(1000);
                  
                      //close the POPUP if the button with id="close" is clicked
                      $("#close").on("click", function (e) {
                          e.preventDefault();
                          $("#popup").fadeOut(1000);
                      });
                  
                  });
                  

                  脚本的行为是这样的:当页面加载时,<div id="popup">里面的内容会显示出来,如果带有id="close的按钮" 被点击,然后弹出窗口被隐藏.在 <div id="popup"> 中添加您想要的任何内容,它会显示在弹出窗口中.

                  The script behaves like this: When the page is loaded, the content inside <div id="popup"> show up, and if the button with id="close" is clicked, then the pop up is hidden. Add whatever you want inside this <div id="popup"> and it will show inside the popup.

                  /*we need to style the popup with CSS so it is placed as a common popup does*/
                      #popup {
                              display:none;
                              position:absolute;
                              margin:0 auto;
                              top: 50%;
                              left: 50%;
                              transform: translate(-50%, -50%);
                              z-index: 9999;
                      }
                  

                  您可以在这个实时示例中看到它与 HTML 一起工作:

                  You can see it working along with the HTML on this live example:

                  这篇关于当有人访问它时,如何在我的主页上自动弹出图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Plot data in website from multiple csv file(从多个 csv 文件中绘制网站中的数据)
                  Content Service for Google Apps Script returning HTML instead of JSON(返回 HTML 而不是 JSON 的 Google Apps 脚本的内容服务)
                  Open page in new window without popup blocking(在新窗口中打开页面而不阻止弹出窗口)
                  Javascript Confirm popup Yes, No button instead of OK and Cancel(Javascript 确认弹出窗口是,否按钮而不是确定和取消)
                  Opensource/free HTML5/CSS3/JavaScript IDE?(开源/免费 HTML5/CSS3/JavaScript IDE?)
                  jump to CSS selector in a css file from the HTML file in Vim using a single keystroke(使用单次击键从 Vim 中的 HTML 文件跳转到 CSS 文件中的 CSS 选择器)

                    <small id='3WMZb'></small><noframes id='3WMZb'>

                    1. <i id='3WMZb'><tr id='3WMZb'><dt id='3WMZb'><q id='3WMZb'><span id='3WMZb'><b id='3WMZb'><form id='3WMZb'><ins id='3WMZb'></ins><ul id='3WMZb'></ul><sub id='3WMZb'></sub></form><legend id='3WMZb'></legend><bdo id='3WMZb'><pre id='3WMZb'><center id='3WMZb'></center></pre></bdo></b><th id='3WMZb'></th></span></q></dt></tr></i><div id='3WMZb'><tfoot id='3WMZb'></tfoot><dl id='3WMZb'><fieldset id='3WMZb'></fieldset></dl></div>
                        <tbody id='3WMZb'></tbody>

                      <tfoot id='3WMZb'></tfoot>
                      <legend id='3WMZb'><style id='3WMZb'><dir id='3WMZb'><q id='3WMZb'></q></dir></style></legend>

                          <bdo id='3WMZb'></bdo><ul id='3WMZb'></ul>