/    Sign up×
Community /Pin to ProfileBookmark

Need a replace script to replace text with text + image (have code, need help fixing)

I have the following code:

[CODE]<!– Add Lifestyle Logo –>
<script type=”text/javascript”>
var words={
‘Exclusive Lifestyle Family Fitness Offer’:’Exclusive Lifestyle Family Fitness Offer! <img src=images/logos/lifestyle_fitness_logo_tiny.jpg>’
}
var regs=[];
for(arg in words){regs[regs.length]=new RegExp(arg,’g’)}

<!–[if IE]> window.onload += <![endif]–>
function replaceText(){
var tags=document.getElementsByTagName(‘body’)[0].getElementsByTagName(‘*’);
var i=0,t;
while(t=tags[i++]){
if(t.childNodes[0]){
var j=0, c;
while(c=t.childNodes[j++]){
if(c.nodeType==3){
var k=0;
for(arg in words){
c.nodeValue=c.nodeValue.replace(regs[k],words[arg]);
k++;
}
}
}
}
}
}

</script>
[/CODE]

All it does is output text blah blah <img src=””> instead of showing the text and displaying the image.. is there a way to get this to work?

Thanks!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @cinematic_jesi 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.18,
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,
)...