/    Sign up×
Community /Pin to ProfileBookmark

How do I use javascript to check if text appears on web page?

Hi guys. I’m trying to write a macro, but I’m lost. So say if I have an array of keywords to check for on a web page,

[CODE]

var keywords=new Array();

keywords[0]=”You are a cat”;
keywords[1]=”Are you a robot”;
keywords[2]=”Have a good summer”;

[/CODE]

How would I make a function that checks the currently opened web page for one of the specific keywords. And if that keyword is found, then execute some action – and if not, then execute some other action?

Thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@PadonakJul 08.2010 — for doing this you have to check does the target page element (where you are going to show these phrases) contain the given word or not. document.getElementById(target_element_id).innerHTML is to be checked
×

Success!

Help @laniyar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...