【问题标题】:how to add a code in php echo so it will be as a popup window when called?如何在 php echo 中添加代码,以便在调用时将其作为弹出窗口?
【发布时间】:2013-12-03 14:54:56
【问题描述】:

我想插入一些 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回显弹出框? 如果您需要更多详细信息,请告诉我。任何帮助将不胜感激。在此先感谢:)

【问题讨论】:

  • 弹出框可以通过javascript而不是php提供你也可以使用JQuery UI对话框进行更多交互
  • PHP 本身是服务器端编程语言,它不能自行创建弹出窗口。您将需要客户端脚本作为 JS 或 DHTML 类型来执行此操作。
  • @Pranav c 我已经创建了上面的 html、javascript 和 css 代码。这是一个外观相似的弹出框。但是如何把它放在php中? @ Dainis Abols 我不希望 php 为我创建一个弹出窗口。我需要的只是将上述代码集成到 php echo 中。两者:感谢您的帮助:)
  • 与 html 中的 php 代码相同,您可以在 &lt;?php //php code here ?&gt; 中编写
  • 不支持IE6,没必要。甚至 IE8 也即将淘汰

标签: javascript php html popup window


【解决方案1】:

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

这就是你要找的东西吗?

【讨论】:

  • @Ash King 实际上没有。我想将代码放在 php echo 中,而不是放在代码中的 php echo 中:P。但是感谢您的尝试:)
  • 嗯,它是 html 中的 php 回显,但也会回显 html,开始变成一个悖论,但不用担心,哈哈
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-15
  • 1970-01-01
相关资源
最近更新 更多