我在今天的图片网址和链接网址中找到了代码:
在HEAD中:
<script>
Date.prototype.toMyString = function () {
//If month/day is single digit value add perfix as 0
function AddZero(obj) {
obj = obj + '';
if (obj.length == 1)
obj = "0" + obj
return obj;
}
var output = "";
output += this.getFullYear();
output += AddZero(this.getMonth()+1);
output += AddZero(this.getDate());
return output;
}
var d = new Date();
var link = document.getElementById("image");
link.setAttribute("src","http://cache3-img1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=6107"+d.toMyString()+"00000000001001&page=1&scale=67");
var link = document.getElementById("link");
link.setAttribute("href","http://www.pressdisplay.com/pressdisplay/pageview.aspx?issue=6107"+d.toMyString()+"00000000001001");
</script>
在BODY:
<center>
<img id="image" width="300">
<br/>
<a id="link" href="#">Read Today Epaper
<script type='text/javascript'>
<!--
var months = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'];
var myDays = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jum'at', 'Sabtu'];
var date = new Date();
var day = date.getDate();
var month = date.getMonth();
var thisDay = date.getDay(),
thisDay = myDays[thisDay];
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
document.write(thisDay + ', ' + day + ' ' + months[month] + ' ' + year);
//-->
</script></a>
</center>
DEMO:
http://www.epaper.pustakakoran.com/thejakartapost/
如何在图片网址和链接网址中将该代码更改为昨天的日期?谢谢大家。
答案 0 :(得分:0)
您的代码
我使用-1
来获取昨天的日期和日期
以下是您需要的代码。
<a id="link" href="#">Read Today Epaper
<script type='text/javascript'>
<!--
var months = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'];
var myDays = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jum'at', 'Sabtu'];
var date = new Date();
var day = date.getDate();
var month = date.getMonth();
var thisDay = date.getDay(),
thisDay = myDays[thisDay];
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
document.write(thisDay + ', ' + day + ' ' + months[month] + ' ' + year);
//-->
</script></a>
</center>
<a href='#'>Read <script>
var previousday = date.getDate()-1;
var Yesterday = date.getDay(),
Yesterday = myDays[Yesterday-1];
var values = Yesterday + ', ' + previousday + ' ' + months[month] + ' ' + year;
document.write(values);
</script>
</a>
将其放入图片网址并链接网址
<a href='thegotjavascriptvaluehere'>
<img src='https://cdn2.iconfinder.com/data/icons/large-glossy-svg-icons/512/go_back_next_arrow_previous-512.png' height="30px" width="30px">
</a>