【发布时间】:2014-04-18 09:29:38
【问题描述】:
情况如下:
这是一个银行网站,因此当用户点击外部链接(可能是 Facebook 页面或合作伙伴网站)时,需要有一个框显示“您即将离开此页面,没有此内容由...等管理。”。
然后,用户应该能够单击“确认”以在新窗口中打开外部链接,或单击“取消”以返回网站并显示“您已选择不离开地点”。
此站点位于 Wordpress 中,因此我正在寻找一种无需为每个链接添加自定义 Javascript 的简单方法来处理此问题。
他们实际上已经在他们现有的网站上运行它:http://clearmountainbank.com/ 我可以通过在标题中添加一个 confirm_entry 脚本并为每个链接添加自定义 Javascript 来使其在新站点上运行,但我无法获得指向的链接在新窗口中打开。
这种方式也很耗时,因为我必须手动编辑每个外部链接。是否有任何简单的方法可以识别外部链接并在整个站点中添加此功能,如果没有,我该怎么做才能使其在新窗口中打开?
这是我正在使用的代码:
<script type="text/javascript">
<!--
function confirm_entry(varible_value)
{
input_box=confirm("Link Disclaimer: Bank Name provides links to web pages which are not part of the Bank Name website or clearmountainbank.com or online.bankname.com domains. These sites are not under Bank Name control, and Clear Mountain Bank is not responsible for the information or links you may find there. Bank Name is providing these links only as a convenience. The presence of these links on any Bank Name website is not intended to imply Bank Name endorsement of that site, but to provide a convenient link to relevant sites which are managed by other organizations, companies, or individuals.");
if (input_box==true)
{
window.location.href=varible_value;
}
else
{
// Output when Cancel is clicked
alert ("You have opted not to leave Bank's website.");
}
}
-->
</script>
【问题讨论】:
标签: javascript php jquery html wordpress