Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
when we write :) or :p or something else on facebook chat Smile | :) or other sites that supports smiley. This code changes to smiley image. thats mean javascript replace that short code (":P") etc to a image. so first we have to find that code (":P") from a text like (" hello friens :P how are you?") after finding that we have to replace with it proper image.

Blogger does not support img tag to post in comment. so there is only way that we can use [img]
(image source url)[/img] and our javascript code finds the [img][/img] tag and then extract the image url from it and replace it with a image.
so this is to be written in javascript i think.
1.use var data = document.getElementById("Id-of-comment").innerHTML;
2. We get data. now we have to find the [img]...[/img] tag {data.search("[img]"); possibly)
3. now we have to obtain the link in a variable.
4. now we have to replace [img]......[/img] with <img src="(variable-that-stores-the-image-url)></img>

Thats all.
[img]https://www.gravatar.com/avatar/4ce47f47105a3bd1ca4700f02b5deff1?s=32&d=identicon&r=PG[/img]


<script>
function myFunction() {
var n;
var m;
var p;
var s;
s = document.getElementById("mm").innerHTML
n = s.search("[img]");
m = s.search("[/img]");
p = s.slice(n,m);
s = s.replace("[img]","'");
s = s.replace("[/img]","'");
alert(p + n + m);
var b;
b = ""
document.getElementById("mm").innerHTML = b;
}
</script>
Posted
Comments
[no name] 19-Jun-14 11:31am    
This looks like you are posting the answer to your own question instead of actually asking a question.
Mrinmoy Das 19-Jun-14 11:36am    
not at all, i write it in this manner because one can understand what i want to ask ...actually the script is not working. i want to know the exact code that solves that.
[no name] 19-Jun-14 11:44am    
Then you need to edit your original question instead of reposting.

1 solution

The solution given by Snesh to your previous question is working perfectly.

Just to support that, I have created a Demo - [Demo] Replace Image Tags in Blogger with actual Image[^]. See how it is working.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900