简体   繁体   English

没有地址栏的弹出窗口

[英]PopUp window with no address bar

I seem to remember reading that modern browsers try to stop the hiding of the address bar of a popup window, but there were ways around this.. 我似乎记得曾经读过,现代的浏览器试图阻止隐藏弹出窗口的地址栏,但是有一些解决方法。

Currently I'm using this code : 目前,我正在使用此代码:

<script language="javascript">
    var popupWindow = null;
    function centeredPopup(url,winName,w,h,scroll){
        LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
        TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
        settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
        popupWindow = window.open(url,winName,settings)
    }
</script>

<img onClick="centeredPopup('test.php','test','400','400','yes');return false" src="test.png">

In Safari it works great the popup shows with no address bar, but in Chrome, IE11 and Firefox the address bar is shown. 在Safari中,它很好用,没有地址栏的弹出窗口显示,但是在Chrome,IE11和Firefox中,显示了地址栏。

Is there anyway this can work with out the address bar in all the browsers I've listed, or can it be done using other code ? 无论如何,这在我列出的所有浏览器中都可以在地址栏中使用,还是可以使用其他代码来完成? javascript, jquery, php ? javascript,jquery,php?

All I'm after is a simple popup that starts at a specific size, but is moveable, resizeable and scrollable if needed. 我所需要的只是一个简单的弹出窗口,该弹出窗口以特定的大小开始,但是在需要时可以移动,调整大小和滚动。

Thanks 谢谢

** UPDATE ** **更新**

I have this sort of working. 我有这种工作。 The dialog appears with scroll bars but I can't scroll. 对话框出现滚动条,但我无法滚动。

Any ideas ? 有任何想法吗 ? This FIDDLE shows what I mean. 这个FIDDLE显示了我的意思。

Maybe I'm getting something wrong, but just in case: The Fiddle you provided has set scrolling to "no" in the html. 也许我弄错了,但以防万一:您提供的Fiddle将html中的滚动设置为“否”。 Once its set to "yes", its scrolling perfectly :) 一旦将其设置为“是”,它就会完美滚动:)

<div id="dialog" style="display:none;" title="Dialog Title"><iframe frameborder="0" scrolling="yes" width="100%" height="100%" src="http://google.about.com/"></iframe></div>

You can do something similar: 您可以执行类似的操作:

<a class="test" href="www.somesite.com">Test</a> 
<div id="somediv-wrap">
  <div id="somediv">

  </div>
</div>

<script>
    $(document).ready(function() {  

        $("#somediv-wrap").dialog({
                  autoOpen: false,
                   width: 400, 
                   height:200,
                   modal: true
                  });  

        $(".test").click(function(event)
          {
              event.preventDefault();
              var link = $(this).attr('href');

              $("#somediv").load(link,function(){
               $( "#somediv-wrap" ).dialog( "open" );   
              });                        
      });
   });
</script>

You create your dialog, and when it is opened, an html file is loaded from your server, replacing the contents of your <div id="somediv"></div> , which should be inside your dialog <div class="somediv-wrap"/> . 创建对话框,然后打开对话框,从服务器加载一个html文件,替换<div id="somediv"></div> ,该内容应在对话框中<div class="somediv-wrap"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM