如何在php echo中添加代码,以便在调用时作为弹出窗口?

时间:2013-12-03 14:54:57

标签: javascript php html popup window

我想插入一些PHP来显示弹出框。我有以下HTML / CSS / Javascript代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style>
        .poppup_overlay{ 
            display: none;
            position:fixed;
            top: 0%;
            left: 0%;
            width: 100%;
            height: 100%;
            background-color: black;
            background-position:fixed;
            z-index:1001;
            -moz-opacity: 0.8;
            opacity:.80;
            filter: alpha(opacity=80);
        }

        * html .poppup_overlay { /* ie6 hack */
            position: absolute;
            height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
        }

        .poppup_content {
            display: none;
            position:fixed;
            width:450;
            height:110;
            top: 40%;
            left: 35%;
            padding: 4px;
            border: 3px solid #009933;
            background-color: white;
            z-index:1002;
            overflow: auto;
        }

        * html .poppup_content { /* ie6 hack */
            position: absolute;
            margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
        }

        .button {
            display:block;
            font-weight:normal;
            font-size:18px;
            font-family:Calibri;
            color:#009933;
            background-color:#ffffff;
            width:100px;
            text-decoration:none;
            text-align:center;
            padding:4px;
            border-top: 2px solid #b2b2b2;
            border-bottom: 2px solid #b2b2b2;
            border-left: 2px solid #b2b2b2;
            border-right: 2px solid #b2b2b2;
        }

        .button:hover,.button:active {
            background-color:#fff;
            border-color:#009933;
        }
    </style>

</head>

<body>

    <p>
        Click <a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">here</a>
    </p>

    <div id="light" class="poppup_content">

        <table>
            <tr>
                <td><img src="popname.png" /></td>
            </tr>
            <tr></tr>
            <tr>  
                <td><font color="#009933" face="calibri">Your message has been successfully sent !</font></td>
                <tr></tr>
            </tr>
        </table>  

        <p align="right">
            <a class="button" href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a>
        </p>

    </div>

    <div id="fade" class="poppup_overlay"></div>

</body>
</html>

您可以在线测试here

我的问题是如何在php echo中集成此代码,以便php回显弹出框? 如果您需要更多细节告诉我。任何帮助将受到高度赞赏。在此先感谢:)

1 个答案:

答案 0 :(得分:0)

<p>Click <a href = <? echo "javascript:void(0)\" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'\""?>>here</a></p>

这是你在寻找什么?