Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
374 views
in Technique[技术] by (71.8m points)

javascript - 代码在预览wordpress页面时有效,但在查看已发布页面时无效(Code works when previewing a wordpress page, but not when viewing the published page)

I have a site through Wordpress.

(我有一个通过Wordpress的网站。)

On this site, I added some code to my homepage.

(在此站点上,我向主页添加了一些代码。)

When I clicked the 'preview updates' button in the edit page, it brought me to preview page where the code was functioning properly.

(当我单击编辑页面中的“预览更新”按钮时,它使我进入了代码正常运行的预览页面。)

So, I clicked the update page button and went to check it out.

(因此,我单击了更新页面按钮,然后进行了检查。)

To my great dismay, I found that my code did not work.

(令我非常沮丧的是,我发现我的代码无法正常工作。)

I ran it with an html tester, and it worked fine there as well.

(我使用html测试器运行它,并且在那里也能正常工作。)

I have repeated the previous process multiple times, and have gotten no further.

(我已经重复了前面的过程多次,并且没有得到更多。)

This is the code I used:

(这是我使用的代码:)

    <script language="javascript">
var pic='';
mytime=new Date();
mymonth=mytime.getMonth()+1;
mydate=mytime.getDate();
if (mymonth==12 && mydate<=7){pic="A<img src='https://docs.google.com/drawings/d/e/2PACX-1vSacccpe1ePniRET6J7Rt_GMuJKl-MTamK-y_9UnfDELETING FOR PRIVACY-vWc8aYZ/pub?w=1384&amp;h=636' alt='NEW Notif'>";
}
else if (mymonth==11 && mydate<=30){pic="B<img src='https://docs.google.com/drawings/d/e/2PACX-1vSacccpe1ePniRET6J7Rt_GMuJKl-MTamK-y_9UnfDELETING FOR PRIVACY-vWc8aYZ/pub?w=1384&amp;h=636' alt='m11'>";
}
else if (mymonth==12 && mydate>=8){pic="C<img src='https://docs.google.com/drawings/d/e/2PACX-1vQ4qWKJx8SQzNpUgUjpKvid6MPbohLwkn__KKqj5_DELETING FOR PRIVACY-XB-3d2iVq/pub?w=1384&h=636' alt='Copy of Notif'>";
}
else {
pic="<b>An error has occurred - notifications will not be shown</b>"
}
document.write(pic);
</script>

Basically all this code does is display a notification, but it automatically updates the notification if that event (talked about in the notification) has passed.

(基本上,这些代码所做的只是显示一个通知,但是如果该事件(在通知中谈到)已经过,它将自动更新通知。)

I'd be more than open to other methods of doing this (just no jQuery!), as long as they would solve/get around my issue.

(只要他们能够解决/解决我的问题,我就会对其他这样做的方法持开放态度(只是没有jQuery!)。)

I'm a bit of a newbie.

(我有点新手。)

Thanks in advance!

(提前致谢!)

Rob

(抢)

  ask by Rob translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...