如何使用javascript在博客中发布图片 [英] How to post image in blogger with javascript

查看:66
本文介绍了如何使用javascript在博客中发布图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们在facebook上写:)或:p或其他东西时聊天微笑| :)或其他支持笑脸的网站。此代码更改为笑脸图像。这意味着javascript将短代码(:P)等替换为图像。所以首先我们必须从文本中找到代码(:P)(你好朋友:P你好吗?),然后发现我们必须用它替换正确的图像。



Blogger不支持img标签发表评论。所以我们只能使用[img]

(图像源网址)[/ img],我们的javascript代码找到[img] [/ img]标签,然后从中提取图片网址它用图像替换它。

所以这是用javascript写的。我想是。

1.use var data = document.getElementById(Id-of-评论)。innerHTML;

2.我们得到数据。现在我们必须找到[img] ... [/ img]标签{data.search([img]);可能)

3.现在我们必须获取变量中的链接。

4.现在我们必须替换[img] ...... [/ img ]< img src =(variable-that-stores-the-image-url)>< / img>



多数民众赞成。

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





< script>

函数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>

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>

推荐答案

Snesh给出的解决方案您以前的问题工作得很好。



为了支持这一点,我创建了一个演示 - [演示]用实际图像替换Blogger中的图像标签 [ ^ 。看看它是如何工作的。
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.


这篇关于如何使用javascript在博客中发布图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆