弹出带有隐藏URL地址的窗口

时间:2014-03-20 02:04:55

标签: javascript html

尝试在javascript中隐藏弹出窗口的URL地址时遇到了一些困难。这是我的HTML:

<div id="menu">
    <ul>
        <li><a onclick="PopupCenter('./about.html', 'About ePlanner',600,400);" href="javascript:void(0);">About ePlanner</a></li>
        <li><a onclick="PopupCenter('./team.html', 'Project Members',600,400);" href="javascript:void(0);">Project Members</a></li>
        <li><a onclick="PopupCenter('./faq.html', 'FAQ',600,400);" href="javascript:void(0);">FAQ</a></li>
</div>

我弹出窗口的javascript:

<script>
function PopupCenter(pageURL, title,w,h) {
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var targetWin = window.open (pageURL,title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 
</script>

我想知道是否可以隐藏URL地址以及窗口框架。

enter image description here 提前谢谢。

2 个答案:

答案 0 :(得分:0)

看起来你可以在这里找到没有菜单栏的答案: Opening javascript popup window without address bar and title with height and width set in percentage according to screen resolution

尝试不使用此代码的代码:

<script language="Javascript">
<!--
var Width=200 // window width
var Height=200 // window height
var Left = (screen.width/2)-(Width/2) // center
var Top = (screen.height/2)-(Height/2) // center
var Autoclose = true

function openFrameless(url){
FrameLess = window.open(url,"noframewin","fullscreen") 
FrameLess.document.body.style.overflow="auto" // auto scrollbars
FrameLess.resizeTo(Width,Height) // resize
FrameLess.moveTo(Left,Top) // position
FrameLess.focus()

if (Autoclose){
window.onunload = function(){
FrameLess.close()
}
}
}
// -->
</script> 



<a href="#null" onclick="openFrameless('YOURPAGE.htm')">Open Frameless</a> 

答案 1 :(得分:0)

要实现没有框架的 Chrome 弹出窗口,请尝试此处的代码(您可能需要对html网页中的内容进行硬编码或与iFrame集成 - 如果您需要帮助,请告诉我们): http://www.sitepoint.com/forums/showthread.php?1175628-Remove-browser-box-border-from-pop-up-window

以上资源中的示例[在我的Chrome浏览器中使用无框架/无边框/地址免费弹出窗口效果很好]:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- only for this testpage! --><meta name="robots" content="noindex, nofollow" />
<!-- http://www.sitepoint.com/forums/showthread.php?1175628-Remove-browser-box-border-from-pop-up-window -->
    <meta name="Description" content="Choose an Asheville painting company dedicated to providing the highest quality work while getting the job completed on budget and on time. SCI Painting in Burnsville near Asheville NC." />
    <meta name="Keywords" content="painting company,exterior paint company,interior paint company" />
    <meta name="author" content="SCI Painting" />
    <meta name="copyright" content="2013 SCI Painting" />
    <link rel="shortcut icon" href="http://scipainting.com/images/favicon.ico" />
    <link href="http://scipainting.com/css/style.css" rel="stylesheet" type="text/css" />
<!--
http://www.sitepoint.com/forums/showthread.php?1175628-Remove-browser-box-border-from-pop-up-window
Thread: Remove browser box/border from pop up window
Oct 31, 2013, 11:11
Sculley
Code by Francky
-->
    <title>test :: Choose a Quality Asheville Painting Company</title>
    <style type="text/css">
html {
    height:100%;
    overflow-y:scroll;
}
#grayOverlay {
    position:fixed;
    left:0;
    top:0;
    width:100%;
    height:100%;
    background-color:#000;
    opacity:.7;
    z-index:1;
    display:none;
}
#center {
    position:relative;
}
#popupBox {
    top:25px;
    left:25px;
    right:25px;
    bottom:0;
    overflow:auto;
    background:#f5f5eb;
    border:1px solid #e0e2cc;
    padding:10px;
    text-shadow:1px 1px white;
    z-index:1;
}
h2 {
    font-size:1.1em;
    font-weight:normal;
}
#closePopupBox1,
#closePopupBox2 {
    position:absolute;
    right:0;
    display:none;
}
#closePopupBox1 a,
#closePopupBox2 a {
    margin:15px;
    padding:0 4px;
    border:1px solid #c0c0c0;
    border-radius:6px;
    background:red;
    color:white;
    font-size:.8em;
    font-weight:bold;
}
</style>

</head>
<body>
<div id="grayOverlay"></div>
<div id="main">
    <div id="top">
        <div id="header"> 
            <div class="header"><br />
                MARC JACKSON<br />
                <a href="mailto:mjackson@scipainting.com">mjackson@scipainting.com</a><br />
                phone 828.442-4107<br />
                fax 828.645.6284<br />
                65 Monticello Rd./<br />
                Weaverville  NC 28787
            </div><!--end div .header -->
        </div><!--end div #header -->
    </div><!--end div #top -->

    <div id="top-navi">
    </div><!--end div #top-navi -->

    <div id="mid">
        <div id="left-side">
            <a href="#popupBox" onclick="openPop();return false">
                <img width="125" height="60" alt="What others say" src="http://scipainting.com/images/quote-web.jpg" />
            </a>
            <img src="http://scipainting.com/images/image1-shadow.png" width="148" height="158" class="first" alt="Image 1" />
            <img src="http://scipainting.com/images/image2-shadow.png" width="138" height="141" alt="Image2" />
            <img src="http://scipainting.com/images/image3-shadow.png" width="138" height="141" alt="Image 3" />
        </div><!--end div left-side -->

        <div id="center">
            <div align="center"><img src="http://scipainting.com/images/image-main.jpg" width="634" height="292" 
                alt="SCI Painting in Burnsville NC near Asheville, NC" />
            </div>

            <div class="txtbox">
                <p>Residential and Commercial <br />
                projects</p>
                <p>Interior and exterior paint <br />
                and stain services</p>
                <p>Roof and floor coatings</p>
                <p>Deck maintenance and cleaning</p>
                <p>Pressure washing</p>
                <p>Log home protection</p>
                <p>Faux finishes</p>
            </div><!--end div .txtbox -->

            <p>SCI Painting was founded to meet the demand for high quality painting and excellent customer service.  
            The joining of two family businesses, Sineath Construction’s paint division and C. Manning Paint Service, 
            provides all of western North Carolina with unmatched services, excellence and value important to families 
            today.  These two companies together bring over 40 years of experience, quality work, reliable service and 
            a long list of satisfied customers to SCI Painting.  We are fully licensed and insured and look forward to 
            being your choice in paint companies.</p>

            <p>Marc Jackson, manager, is focused on keeping pace with the growing needs of clients in western North 
            Carolina and the challenges that our harsh climate can create.  He, along with our experienced employees, 
            understands the details of all jobs, residential and commercial.  Marc is dedicated to providing the highest 
            quality work while getting the job completed on budget and on time.  Marc is not satisfied until the customer 
            is satisfied.  This is all possible because of clear communication that is maintained with the client before, 
            during, and after the project.</p>

            <div id="popupBox">
                <h2 id="popHeader">People say...</h2>
                <div id="closePopupBox1"><a href="#" onclick="closePop();return false">X</a></div>
                <p>Meredith Ledford</p>
                <p>August 21, 2013</p>
                <p>Marc Jackson<br />
                SCI Painting<br />
                65 Monticello Rd.<br />
                Weaverville, NC 28787</p>
                <p>Dear Mr. Jackson,</p>
                <p>I am writing to you to reiterate my deepest gratitude for the exceptional 
                work SCI Painting<br />
                completed in our new home.</p>
                <p>My husband and I were especially impressed given the large scope of the 
                job and the limited amount of time afforded to you for completion.</p>
                <p>Your team of professional painters arrived on the first day eager to 
                begin and they remained productive and enthusiastic until the job was 
                completed. Because my husband was out of town, I interacted with your crew 
                the majority of the time. They were always very friendly and accommodating.<br /> 
                I was especially touched when they 
                presented with great pride to me the freshly painted nursery – it was 
                beautiful! I also appreciated their patience as I decided which color to 
                paint the trim. I struggled with the decision, but I never felt rushed.</p>
                <p>Because of SCI Painting’s excellent service, my husband and I were able 
                to complete our move into our new home before our son was born. Now we 
                admire your handiwork every day in our new home and marvel at the how 
                efficiently your crew completed the work. SCI Painting is a first rate 
                business that strikes the rare balance of value and professionalism. We are 
                so grateful that we were referred to you for the huge job our home presented 
                and would enthusiastically recommend your services to anyone.</p>
                <p>Thanks again and we hope to see you at &quot;The Rock&quot; this fall for some ASU 
                football. Go APPS!</p>
                <p>Sincerely,</p>
                <div id="closePopupBox2"><a href="#" onclick="closePop();return false">X</a></div>
                <p>Meredith &amp; Dwayne Ledford</p>
            </div><!-- end div #popupBox -->

        </div><!--end div #center -->
    </div><!--end div #mid -->
</div><!--end div main -->

<div id="footer">
    <div class="copyright">
        <p>&copy; Copyright 2013 scipainting.com | All Rights Reserved <br />
            SCI Painting is a partnership with <a href="http://www.sineathconstruction.com/">Sineath Construction in 
            Weaverville, NC near Asheville, NC</a></p>
    </div><!--end div .copyright -->
    <div class="copyright">
        <p>phone 828.645.6284 | fax 828.682.0676 | 65 Monticello Rd. | P.O. Box 1603 | Weaverville NC 28787</p>
    </div><!--end div .copyright -->
</div><!--end div footer -->

<script type="text/javascript">
//<![CDATA[
document.getElementById('popupBox').style.position="absolute";
document.getElementById('popupBox').style.display="none";
document.getElementById('popHeader').style.display="none";
document.getElementById('closePopupBox1').style.display="block";
document.getElementById('closePopupBox2').style.display="block";

function openPop(){
    document.getElementById('popupBox').style.display="block";
    document.getElementById('grayOverlay').style.display="block";
}

function closePop(){
    document.getElementById('popupBox').style.display="none";
    document.getElementById('grayOverlay').style.display="none";
}
//]]>
</script>

</body>
</html>