如何使用JavaScript将一些文本添加到文档标题的末尾?

时间:2017-02-20 14:52:23

标签: javascript html title

我有这样的基本HTML:

with CTE as
(
select a.new_mprnnumber, 
       a.new_customernumber,
       b.*, 
       row_number() 
         over (partition by new_customernumber -- add additional partitions as you would group bys
               order by billingPeriodEndDate desc) as r_ord 
from AccountExtensionBase a
inner join bill  b
  on a.new_mprnnumber = b.MPRN
where new_accountstage = 7
and new_accounttype = 2 
)
select *
from CTE
where r_ord = 1

" @"我需要拥有域名(" EKS.RU"),我认为JS是解决该问题的最佳解决方案。

因此,如果我需要更改域名,我需要在一个脚本文件中简单地编辑部分文本。

4 个答案:

答案 0 :(得分:0)

你可以使用Javascript来做到这一点,你所要做的就是找到title属性,然后添加它的文本window.location.hostname,它将返回页面的域。

document.title += window.location.hostname;

答案 1 :(得分:0)

使用document.title:

非常简单
var domain = 'your.domain';
document.title += domain;

只需将域变量更改为您想要的任何内容。另外,请确保将其放在关闭正文标记之前的脚本标记中,以防您向其添加其他代码。

答案 2 :(得分:0)

您可以使用document.title 获取设置页面标题,因此对于您的情况,您可以执行以下操作。

document.title += "EKS.RU";

答案 3 :(得分:0)

您可以简单地追加以下值:

document.title += "this text added at the end of title";