href = mail到代码执行结束吗?

问题描述 投票:0回答:2

我正在修改一个旧网站,但是我遇到了javascript问题,希望有人可以帮我解释一下。在此网站上,有一个location.href="mailto:..."语句。 mailto之后,有一些代码有望运行。在此网站的旧版本中,此代码可以正常运行,但是在我的版本中,该代码似乎在mailto之后停止运行。关于此声明,我有不明白的地方吗?这是正常现象,还是意味着我的代码有问题?

该网站使用php。这是一些示例代码。

<script type="text/javascript">
    location.href="mailto:[email protected]";
    document.write("echo")
</script>

echo语句将不会运行,并且关闭脚本标记后的php中的任何内容也不会执行。例如:<?php echo "hi"; ?>

javascript mailto
2个回答
1
投票
window.open('mailto:[email protected]', '_blank');

(最终结果:<script type="text/javascript">window.open('mailto:[email protected]', '_blank'_;document.write("echo")</script>

这将在新选项卡中打开mailto,并允许其余代码继续运行。

1
投票
window.open('mailto:[email protected]', '_blank');

(最终结果:<script type="text/javascript">window.open('mailto:[email protected]', '_blank'_;document.write("echo")</script>

这将在新选项卡中打开mailto,并允许其余代码继续运行。
© www.soinside.com 2019 - 2024. All rights reserved.