我一生都无法弄清楚如何将此javascript函数存储在php变量中。基本上我想将此函数作为标准字符串存储在 php 变量中,然后将其打印在页面上。我知道我必须转义 javascript 才能让它与 PHP 一起使用,但我坚持这样做的原因是因为这个特定的 Javascript 和 HTML 组合似乎同时使用了 " 和 ' 所以我不知道如何躲开它。也许你们能帮帮我?
这是我要存储在 php 变量中的代码:
<a href='javascript:PopupContact_OpenForm("PopupContact_BoxContainer","PopupContact_BoxContainerBody","PopupContact_BoxContainerFooter");'><img src='/popup-contact-form.jpg' /></a>
<div style="display: none;" id="PopupContact_BoxContainer">
<div id="PopupContact_BoxContainerHeader">
<div id="PopupContact_BoxTitle">Contact Us</div>
<div id="PopupContact_BoxClose"><a href="javascript:PopupContact_HideForm('PopupContact_BoxContainer','PopupContact_BoxContainerFooter');">Close</a></div>
</div>
<div id="PopupContact_BoxContainerBody">
<form action="#" name="PopupContact_Form" id="PopupContact_Form">
<div id="PopupContact_BoxAlert"> <span id="PopupContact_alertmessage"></span> </div>
<div id="PopupContact_BoxLabel_Page"> Your Name </div>
<div id="PopupContact_BoxLabel_Page"><input name="PopupContact_name" class="PopupContact_TextBox" type="text" id="PopupContact_name" maxlength="120"></div>
<div id="PopupContact_BoxLabel_Page"> Your Email </div>
<div id="PopupContact_BoxLabel_Page"><input name="PopupContact_email" class="PopupContact_TextBox" type="text" id="PopupContact_email" maxlength="120"></div>
<div id="PopupContact_BoxLabel_Page"> Enter Your Message </div>
<div id="PopupContact_BoxLabel_Page"><textarea name="PopupContact_message" class="PopupContact_TextArea" rows="3" id="PopupContact_message"></textarea></div>
<div id="PopupContact_BoxLabel_Page"><input type="button" name="button" class="PopupContact_Button" value="Submit" onClick="javascript:PopupContact_Submit(this.parentNode,'/popup-contact-form/');"></div>
</form>
</div>
</div>
<div style="display: none;" id="PopupContact_BoxContainerFooter"></div>
希望你能明白我的意思,我想将它存储在我的 $button 变量中
谢谢!