/    Sign up×
Community /Pin to ProfileBookmark

Use JavaScript To Rewrite HTML

is there a way that the following may be done:

1.) Copy HTML

2.) Paste into text box

3.) Click “Process” Button

starting from here…
——————————————————-

4.) Upon hitting the “Process” button, JavaScript proceeds to go thru the text, and replace specific strings as designated by the JavaScript program.

For example:
the string “dog” is replaced with the string “<a href=”dogs.html”>dog</a>”
the string “cars” is replaced with the string “<a href=”cars.html”>cars</a>”

and so on….

where I presume there would have to be a database, stored as an array, or something somehow, where

if string is “dog” then replace with “<a href…etc>”
if string is “cars” then replace with “<a href…etc2>”

and so on and on for every string you seek to replace, and so there could be hundreds and hundreds.

At the conclusion of step 4,

5.) JavaScript outputs the new text into a new text box.


———————————————

I hope I explained this clearly enough.

Thank you,
erik

(and if anyone also may know of any relevant sources with respect to this, i tryed searching the forums and didn’t come up with much.)

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@IcedfuseauthorNov 24.2009 — or that database, (or array) which specifies all the conditions may be stored directly within the JavaScript program????
Copy linkTweet thisAlerts:
@slaughtersNov 24.2009 — Yes
×

Success!

Help @Icedfuse 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.2,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...