简体   繁体   English

通过mailto在主题行中显示当前页面的url?

[英]Current page url in subject line via mailto?

How to populate current page title (or current url) to the subject line via mailto? 如何通过mailto将当前页面标题(或当前URL)填充到主题行?

Been using the code below as a starting point, obviously modifying the "Page Title Here" bit, but can't find a solution: 一直使用下面的代码作为起点,显然修改了“此处的页面标题”位,但找不到解决方案:

<?php echo "<a href='mailto:test@test.com" . $to . "?subject=Page Title Here" . $subject . "'>Send an email</a>";?>

Set page title to php var as 将页面标题设置为php var as

$title = 'Example';

and use it for 并用于

<title><?=$title;?></title>

and mail 和邮件

 <?php echo "<a href='mailto:test@test.com" . $to . "?subject=" . $title . $subject . "'>Send an email</a>";?>

This is not generically possible with PHP. PHP通常无法做到这一点。 PHP has no knowledge of what the page title is, or your HTML structure at all. PHP不知道页面标题是什么,也不知道您的HTML结构。

You will have to go to your code where you set the page title, and use that same variable in your e-mail. 您将必须转到设置页面标题的代码,并在电子邮件中使用相同的变量。 If this PHP code is handling a post from some page or something, you need that page title posted with your form data (which you can get with JavaScript document.title ). 如果此PHP代码正在处理某个页面或某个页面上的帖子,则需要将该页面标题与表单数据一起发布(可通过JavaScript document.title获得)。

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

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