[英]Using Javascript to display an ad based on Text on a page
I know what I want to do should be done with a database, but my programmers are backed up and I want to use some test code to test a concept. 我知道我想对数据库做些什么,但是我的程序员已经备份了,我想使用一些测试代码来测试一个概念。
I want to put up 1 of 5 unique ads on a page. 我想在页面上放置5个独特广告中的1个。 The type of ad will be based on a piece of text located on the page.
广告类型将基于页面上的一段文字。
For example I have 1000 pages showing homes for sale. 例如,我有1000页显示待售房屋。 If that home is in XYZ county, then I want to show an ad called XYZ.jpg.
如果该房屋位于XYZ县,那么我想展示一个名为XYZ.jpg的广告。 However if that home is in ABC County, then I want to show an ad called ABC.jpg
但是,如果该房屋位于ABC县,那么我想展示一个名为ABC.jpg的广告
So can javascript scan a page and if a word is found, display certain text? 那么,javascript可以扫描页面吗?如果找到一个单词,则显示某些文本? Or if not scan a page, at least scan the "County" field.
或者,如果不扫描页面,则至少扫描“县”字段。
Thanks! 谢谢!
if (document.innerText.indexOf('keyword') != -1) {
document.getElementById('ad_div').innerText = "Found " + keyword + "!";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.