如何使用JS从另一个页面检索图像路径
How can I retrieve an image path from another page using JS?
这是我的情况:我有一个页面的横幅会经常更新,这意味着每次更新页面时横幅的图像路径都会不同(无法覆盖)。无论如何,它将位于div或具有常量名称的容器中。
我需要做的是检索该图像路径并将其打印到另一个页面中,因此,如果横幅在第一个页面中发生更改,它将在第二个页面中自动发生更改。
我想也许一些javascript可以完成这项工作,但我真的不确定如何从div内部获取图像路径。
如有任何帮助,我们将不胜感激,来自阿根廷的问候
使用html5和javascript的解决方案就是这个
you can get the image tag through javascript(as u say it is in div
and whose id you know)
something like
src = document.getElementById("id").childnodes[0].src
should work for u
then you can store this src in the localStorage
localStorage["src"] = src;
as soon as you store something in localstorage it will fire a
"storage" event in all the other pages except the page in which
you have actually stored the src
so handle "storage" event in the other pages like this
window.addEventListener("storage",func,false);
function func(event)
{
src = localStorage[event.key];
//now src has the updated src :)
}
相关文章:
- GoogleFeed正在检索图像
- 在Node.js中上传和检索图像
- 存储和检索图像数据URL
- 如何在json对象中包含图像以及如何检索图像
- Parse.com-在JavaScript SDK中模板化集合时检索图像URL
- 如何使用javascript存储然后从Parse中检索图像
- 不从移动角度UI中的JSON检索图像.(角度 js)
- 如何在html/javascript中使用dom检索图像的大小
- 从对象值-angular js中检索图像url
- 从web加载图像后,如何检索图像的本地路径
- 使用Web API从数据库中检索图像,然后将其显示在angularJS中
- 如何使用JS从另一个页面检索图像路径
- 如何在php中使用json检索图像
- 从本地存储检索图像src,单位为$.each
- 最佳可能的方式检索图像从数据库在javascript或jquery
- 检索图像源类或id与php和javascript/JQuery
- 如何检索图像SRC属性从弹出到父页面
- 使用javascript从Parse.com检索图像
- 不能在Safari中使用Javascript检索图像宽度,但在Chrome中工作良好
- 如何使用Ajax从flickr中检索图像