Blogger javascript 无法从 http 到 https
Blogger javascript not working http to https
您好,我刚刚将域从 tecnoriales.win 更改为 tecnoriales.com 并开始使用 SSL (HTTPS)。
我有一个脚本可以创建我所有 post 的存档,但它不再工作了。我对编码知之甚少,所以我没有头绪。
这是代码应加载的页面:https://www.tecnoriales.com/p/sitemap.html
已经查看了一个非常相似的问题: 尝试了他们所说的(或者我认为如此)但我无法解决问题。
<div style="text-align: justify;">
<span style="font-family: "trebuchet ms" , sans-serif;">A
continuación tienes la lista de todas las entradas del blog. Recuerda
que también puedes utilizar la opción Buscar este blog que se encuentra
en la esquina superior izquierda para indagar.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;">
</span></div>
<br />
<script type="text/javascript">
function LoadTheArchive(TotalFeed)
{
var PostTitles = new Array();
var PostURLs = new Array();
var PostYears = new Array();
var PostMonths = new Array();
var PostDays = new Array();
if("entry" in TotalFeed.feed)
{
var PostEntries=TotalFeed.feed.entry.length;
for(var PostNum=0; PostNum<postentries ; PostNum++)
{
var ThisPost = TotalFeed.feed.entry[PostNum];
PostTitles.push(ThisPost.title.$t);
PostYears.push(ThisPost.published.$t.substring(0,4));
PostMonths.push(ThisPost.published.$t.substring(5,7));
PostDays.push(ThisPost.published.$t.substring(8,10));
var ThisPostURL;
for(var LinkNum=0; LinkNum < ThisPost.link.length; LinkNum++)
{
if(ThisPost.link[LinkNum].rel == "alternate")
{
ThisPostURL = ThisPost.link[LinkNum].href;
break
}
}
PostURLs.push(ThisPostURL);
}
}
DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays);
}
function DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays)
{
var MonthNames=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];
var NumberOfEntries=PostTitles.length;
var currentMonth = "";
var currentYear = "";
for(var EntryNum = 0; EntryNum < NumberOfEntries; EntryNum++)
{
NameOfMonth = MonthNames[parseInt(PostMonths[EntryNum],10)-1]
if (currentMonth != NameOfMonth || currentYear != PostYears[EntryNum]) {
currentMonth = NameOfMonth;
currentYear = PostYears[EntryNum];
document.write("<div class='dateStyle'><br />" + currentMonth+" "+currentYear+" </div>
");
}
document.write('<a href ="'+PostURLs[EntryNum]+'"><div class=dayStyle>
'+parseInt(PostDays[EntryNum],10)+": </div>
"+PostTitles[EntryNum]+"</a><br />");
}
}
</script>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=500&alt=json-in-script&callback=LoadTheArchive">
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=151&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=301&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=451&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=601&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=851&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=1001&alt=json-in-script&callback=LoadTheArchive"/>
<!--CUSTOMIZATION-->
<style type="text/css">
.dateStyle {
color:#000;
font-weight:bold;
font-size: 15px;
font-family: Trebuchet MS, sans-serif;
margin: 0;
}
.dayStyle {
color:#000;
font-weight:bold;
font-family: Trebuchet MS, sans-serif;
display: inline-block;
}
</style></script>```
It should load the full list of all the blog post I've made categorized by month and year but it loads nothing.
JavaScript 代码中的换行符会导致语法错误。 PostEntries
变量也被引用为 postentries
。更改 Javascript 如下 -
<script>
function LoadTheArchive(TotalFeed)
{
var PostTitles = new Array();
var PostURLs = new Array();
var PostYears = new Array();
var PostMonths = new Array();
var PostDays = new Array();
if("entry" in TotalFeed.feed)
{
var PostEntries=TotalFeed.feed.entry.length;
for(var PostNum=0; PostNum<PostEntries ; PostNum++)
{
var ThisPost = TotalFeed.feed.entry[PostNum];
PostTitles.push(ThisPost.title.$t);
PostYears.push(ThisPost.published.$t.substring(0,4));
PostMonths.push(ThisPost.published.$t.substring(5,7));
PostDays.push(ThisPost.published.$t.substring(8,10));
var ThisPostURL;
for(var LinkNum=0; LinkNum < ThisPost.link.length; LinkNum++)
{
if(ThisPost.link[LinkNum].rel == "alternate")
{
ThisPostURL = ThisPost.link[LinkNum].href;
break
}
}
PostURLs.push(ThisPostURL);
}
}
DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays);
}
function DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays)
{
var MonthNames=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];
var NumberOfEntries=PostTitles.length;
var currentMonth = "";
var currentYear = "";
for(var EntryNum = 0; EntryNum < NumberOfEntries; EntryNum++)
{
NameOfMonth = MonthNames[parseInt(PostMonths[EntryNum],10)-1]
if (currentMonth != NameOfMonth || currentYear != PostYears[EntryNum]) {
currentMonth = NameOfMonth;
currentYear = PostYears[EntryNum];
document.write("<div class='dateStyle'><br />" + currentMonth+" "+currentYear+" </div>");
}
document.write('<a href ="'+PostURLs[EntryNum]+'"><div class=dayStyle>'+parseInt(PostDays[EntryNum],10)+": </div>"+PostTitles[EntryNum]+"</a><br />");
}
}
</script>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=500&alt=json-in-script&callback=LoadTheArchive" />
您会注意到最后 2 个 document.write
语句删除了换行符
实际问题是你的回调函数没有定义。
因此,将您的函数定义为 function expression。这样函数定义就存在,回调才能工作。
var LoadTheArchive = function (TotalFeed)
var DisplaytheTOC = function (
运行 下面的代码片段,看看它是否有效。加载链接需要一段时间。所以,请耐心等待。
<div style="text-align: justify;">
<span style="font-family: "trebuchet ms" , sans-serif;">A
continuación tienes la lista de todas las entradas del blog. Recuerda
que también puedes utilizar la opción Buscar este blog que se encuentra
en la esquina superior izquierda para indagar.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;">
</span></div>
<br />
<script>
var LoadTheArchive = function(TotalFeed) {
var PostTitles = new Array();
var PostURLs = new Array();
var PostYears = new Array();
var PostMonths = new Array();
var PostDays = new Array();
if ("entry" in TotalFeed.feed) {
var PostEntries = TotalFeed.feed.entry.length;
for (var PostNum = 0; PostNum < PostEntries; PostNum++) {
var ThisPost = TotalFeed.feed.entry[PostNum];
PostTitles.push(ThisPost.title.$t);
PostYears.push(ThisPost.published.$t.substring(0, 4));
PostMonths.push(ThisPost.published.$t.substring(5, 7));
PostDays.push(ThisPost.published.$t.substring(8, 10));
var ThisPostURL;
for (var LinkNum = 0; LinkNum < ThisPost.link.length; LinkNum++) {
if (ThisPost.link[LinkNum].rel == "alternate") {
ThisPostURL = ThisPost.link[LinkNum].href;
break
}
}
PostURLs.push(ThisPostURL);
}
}
DisplaytheTOC(PostTitles, PostURLs, PostYears, PostMonths, PostDays);
}
var DisplaytheTOC = function(PostTitles, PostURLs, PostYears, PostMonths, PostDays) {
var MonthNames = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
var NumberOfEntries = PostTitles.length;
var currentMonth = "";
var currentYear = "";
for (var EntryNum = 0; EntryNum < NumberOfEntries; EntryNum++) {
NameOfMonth = MonthNames[parseInt(PostMonths[EntryNum], 10) - 1]
if (currentMonth != NameOfMonth || currentYear != PostYears[EntryNum]) {
currentMonth = NameOfMonth;
currentYear = PostYears[EntryNum];
document.write("<div class='dateStyle'><br />" + currentMonth + " " + currentYear + " </div>");
}
document.write('<a href ="' + PostURLs[EntryNum] + '"><div class=dayStyle>' + parseInt(PostDays[EntryNum], 10) + ": </div>" + PostTitles[EntryNum] + "</a><br />");
}
}
</script>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=500&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=151&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=301&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=451&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=601&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=851&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=1001&alt=json-in-script&callback=LoadTheArchive" />
<!--CUSTOMIZATION-->
<style type="text/css">
.dateStyle {
color: #000;
font-weight: bold;
font-size: 15px;
font-family: Trebuchet MS, sans-serif;
margin: 0;
}
.dayStyle {
color: #000;
font-weight: bold;
font-family: Trebuchet MS, sans-serif;
display: inline-block;
}
</style>
您好,我刚刚将域从 tecnoriales.win 更改为 tecnoriales.com 并开始使用 SSL (HTTPS)。
我有一个脚本可以创建我所有 post 的存档,但它不再工作了。我对编码知之甚少,所以我没有头绪。
这是代码应加载的页面:https://www.tecnoriales.com/p/sitemap.html
已经查看了一个非常相似的问题:
<div style="text-align: justify;">
<span style="font-family: "trebuchet ms" , sans-serif;">A
continuación tienes la lista de todas las entradas del blog. Recuerda
que también puedes utilizar la opción Buscar este blog que se encuentra
en la esquina superior izquierda para indagar.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;">
</span></div>
<br />
<script type="text/javascript">
function LoadTheArchive(TotalFeed)
{
var PostTitles = new Array();
var PostURLs = new Array();
var PostYears = new Array();
var PostMonths = new Array();
var PostDays = new Array();
if("entry" in TotalFeed.feed)
{
var PostEntries=TotalFeed.feed.entry.length;
for(var PostNum=0; PostNum<postentries ; PostNum++)
{
var ThisPost = TotalFeed.feed.entry[PostNum];
PostTitles.push(ThisPost.title.$t);
PostYears.push(ThisPost.published.$t.substring(0,4));
PostMonths.push(ThisPost.published.$t.substring(5,7));
PostDays.push(ThisPost.published.$t.substring(8,10));
var ThisPostURL;
for(var LinkNum=0; LinkNum < ThisPost.link.length; LinkNum++)
{
if(ThisPost.link[LinkNum].rel == "alternate")
{
ThisPostURL = ThisPost.link[LinkNum].href;
break
}
}
PostURLs.push(ThisPostURL);
}
}
DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays);
}
function DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays)
{
var MonthNames=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];
var NumberOfEntries=PostTitles.length;
var currentMonth = "";
var currentYear = "";
for(var EntryNum = 0; EntryNum < NumberOfEntries; EntryNum++)
{
NameOfMonth = MonthNames[parseInt(PostMonths[EntryNum],10)-1]
if (currentMonth != NameOfMonth || currentYear != PostYears[EntryNum]) {
currentMonth = NameOfMonth;
currentYear = PostYears[EntryNum];
document.write("<div class='dateStyle'><br />" + currentMonth+" "+currentYear+" </div>
");
}
document.write('<a href ="'+PostURLs[EntryNum]+'"><div class=dayStyle>
'+parseInt(PostDays[EntryNum],10)+": </div>
"+PostTitles[EntryNum]+"</a><br />");
}
}
</script>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=500&alt=json-in-script&callback=LoadTheArchive">
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=151&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=301&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=451&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=601&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=851&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=1001&alt=json-in-script&callback=LoadTheArchive"/>
<!--CUSTOMIZATION-->
<style type="text/css">
.dateStyle {
color:#000;
font-weight:bold;
font-size: 15px;
font-family: Trebuchet MS, sans-serif;
margin: 0;
}
.dayStyle {
color:#000;
font-weight:bold;
font-family: Trebuchet MS, sans-serif;
display: inline-block;
}
</style></script>```
It should load the full list of all the blog post I've made categorized by month and year but it loads nothing.
JavaScript 代码中的换行符会导致语法错误。 PostEntries
变量也被引用为 postentries
。更改 Javascript 如下 -
<script>
function LoadTheArchive(TotalFeed)
{
var PostTitles = new Array();
var PostURLs = new Array();
var PostYears = new Array();
var PostMonths = new Array();
var PostDays = new Array();
if("entry" in TotalFeed.feed)
{
var PostEntries=TotalFeed.feed.entry.length;
for(var PostNum=0; PostNum<PostEntries ; PostNum++)
{
var ThisPost = TotalFeed.feed.entry[PostNum];
PostTitles.push(ThisPost.title.$t);
PostYears.push(ThisPost.published.$t.substring(0,4));
PostMonths.push(ThisPost.published.$t.substring(5,7));
PostDays.push(ThisPost.published.$t.substring(8,10));
var ThisPostURL;
for(var LinkNum=0; LinkNum < ThisPost.link.length; LinkNum++)
{
if(ThisPost.link[LinkNum].rel == "alternate")
{
ThisPostURL = ThisPost.link[LinkNum].href;
break
}
}
PostURLs.push(ThisPostURL);
}
}
DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays);
}
function DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays)
{
var MonthNames=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];
var NumberOfEntries=PostTitles.length;
var currentMonth = "";
var currentYear = "";
for(var EntryNum = 0; EntryNum < NumberOfEntries; EntryNum++)
{
NameOfMonth = MonthNames[parseInt(PostMonths[EntryNum],10)-1]
if (currentMonth != NameOfMonth || currentYear != PostYears[EntryNum]) {
currentMonth = NameOfMonth;
currentYear = PostYears[EntryNum];
document.write("<div class='dateStyle'><br />" + currentMonth+" "+currentYear+" </div>");
}
document.write('<a href ="'+PostURLs[EntryNum]+'"><div class=dayStyle>'+parseInt(PostDays[EntryNum],10)+": </div>"+PostTitles[EntryNum]+"</a><br />");
}
}
</script>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=500&alt=json-in-script&callback=LoadTheArchive" />
您会注意到最后 2 个 document.write
语句删除了换行符
实际问题是你的回调函数没有定义。
因此,将您的函数定义为 function expression。这样函数定义就存在,回调才能工作。
var LoadTheArchive = function (TotalFeed)
var DisplaytheTOC = function (
运行 下面的代码片段,看看它是否有效。加载链接需要一段时间。所以,请耐心等待。
<div style="text-align: justify;">
<span style="font-family: "trebuchet ms" , sans-serif;">A
continuación tienes la lista de todas las entradas del blog. Recuerda
que también puedes utilizar la opción Buscar este blog que se encuentra
en la esquina superior izquierda para indagar.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;">
</span></div>
<br />
<script>
var LoadTheArchive = function(TotalFeed) {
var PostTitles = new Array();
var PostURLs = new Array();
var PostYears = new Array();
var PostMonths = new Array();
var PostDays = new Array();
if ("entry" in TotalFeed.feed) {
var PostEntries = TotalFeed.feed.entry.length;
for (var PostNum = 0; PostNum < PostEntries; PostNum++) {
var ThisPost = TotalFeed.feed.entry[PostNum];
PostTitles.push(ThisPost.title.$t);
PostYears.push(ThisPost.published.$t.substring(0, 4));
PostMonths.push(ThisPost.published.$t.substring(5, 7));
PostDays.push(ThisPost.published.$t.substring(8, 10));
var ThisPostURL;
for (var LinkNum = 0; LinkNum < ThisPost.link.length; LinkNum++) {
if (ThisPost.link[LinkNum].rel == "alternate") {
ThisPostURL = ThisPost.link[LinkNum].href;
break
}
}
PostURLs.push(ThisPostURL);
}
}
DisplaytheTOC(PostTitles, PostURLs, PostYears, PostMonths, PostDays);
}
var DisplaytheTOC = function(PostTitles, PostURLs, PostYears, PostMonths, PostDays) {
var MonthNames = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
var NumberOfEntries = PostTitles.length;
var currentMonth = "";
var currentYear = "";
for (var EntryNum = 0; EntryNum < NumberOfEntries; EntryNum++) {
NameOfMonth = MonthNames[parseInt(PostMonths[EntryNum], 10) - 1]
if (currentMonth != NameOfMonth || currentYear != PostYears[EntryNum]) {
currentMonth = NameOfMonth;
currentYear = PostYears[EntryNum];
document.write("<div class='dateStyle'><br />" + currentMonth + " " + currentYear + " </div>");
}
document.write('<a href ="' + PostURLs[EntryNum] + '"><div class=dayStyle>' + parseInt(PostDays[EntryNum], 10) + ": </div>" + PostTitles[EntryNum] + "</a><br />");
}
}
</script>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=500&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=151&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=301&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=451&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=601&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=851&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=1001&alt=json-in-script&callback=LoadTheArchive" />
<!--CUSTOMIZATION-->
<style type="text/css">
.dateStyle {
color: #000;
font-weight: bold;
font-size: 15px;
font-family: Trebuchet MS, sans-serif;
margin: 0;
}
.dayStyle {
color: #000;
font-weight: bold;
font-family: Trebuchet MS, sans-serif;
display: inline-block;
}
</style>