gpt4 book ai didi

javascript - HTA 文件缓存导致重大问题

转载 作者:行者123 更新时间:2023-12-02 18:26:55 26 4
gpt4 key购买 nike

我有一个 JavaScript 函数,它首先获取标签元素的值,该元素是数据库条目的 ID。然后,这些 ID 被发送到 ASP 页面,该页面从数据库中获取图像保存位置。

然后将每个选定图像的保存位置信息发送到 ASP.NET 页面,该页面会分割每个图像保存位置并相应地旋转图像。这一切都很完美,我唯一的问题是,在我重新打开 HTA 文件之前,图像不会更新。

这是我的 JavaScript,它执行旋转:

function doRotate(dir,obj)
{
var http = getHTTPObject();
var http2 = getHTTPObject();
ids = fetchSelection().toString();

//Make button animate, visual aid that it is working
obj.src = "http://localhost/nightclub_photography/images/buttons/"+dir+"_animated.gif";

http.onreadystatechange = function()
{
//Fetch the save location of selected images
if (http.readyState == 4 && http.status == 200) {
//Create URL string to send to rotate script
var locs = http.responseText;
locs = locs.split(",");

//Start of URL
var url = "http://localhost/nightclub_photography/net/rotate_script.aspx?dir=" + dir;

for (var i=0; i < locs.length-1; i++)
{
url = url + "&t=" + locs[i];
}
//Add random math
url = url + "&k=" + Math.random();

http2.onreadystatechange = function()
{
if (http2.readyState == 4 && http2.status == 200)
{

//Stop animated button
obj.src = "http://localhost/nightclub_photography/images/buttons/"+dir+".png";

//Split id's
var idsSplit = ids.split(",");
for (var k=0; k < idsSplit.length; k++) {
reapplyStyle(idsSplit[k]);
}
}
}
http2.open("GET", url);
http2.send();
}
}
http.open("GET", "http://localhost/nightclub_photography/asp/returnDatabaseData.asp?ids="+ids+"&k=" + Math.random());
http.send();
}

我还有一个重新应用(嗯,应该做)背景图像的功能,它应该重新加载旋转的图像。虽然重新加载页面不起作用,所以我也看不到该功能起作用,但这是一个不同的问题。这是函数:

function reapplyStyle(id) {
var background = doc(id+"_label").style.backgroundImage;
doc(id+"_label").style.backgroundImage = background;
}

最佳答案

如果是缓存问题,您是否尝试过使图像网址唯一。尝试这样的事情:

ts = new Date().getTime();
obj.src = "http://localhost/nightclub_photography/images/buttons/"+dir+".png?timestamp=" + ts;

关于javascript - HTA 文件缓存导致重大问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18277571/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com