0

I'm trying to dynamically update the hero image source, inside a TVOS productTemplate.

I'm able to do this for the description, for example:

function changeDescription(incomingString) {
    if (incomingString) {
        var theDescription = myDoc.getElementsByTagName("description").item(0);
        theDescription.innerHTML = incomingString;
    }
}

.. but it's not working for the src value for the hero image:

function changeHeroImage(incomingString) {
    console.log("local path: " + incomingString)
    if (incomingString) {
        var theHero = myDoc.getElementsByTagName("heroImg").item(0);
        var theHeroSrc = theHero.getAttribute("src");
        theHeroSrc.value = incomingString;
        // theHeroSrc.innerHTML = incomingString;
    }
}

I've verified the path is correct; what else should I look at?

4

2 回答 2

0

更新图像应该使用src属性,而不是value

function changeHeroImage(incomingString) {
    console.log("local path: " + incomingString)
    if (incomingString) {
        var theHero = myDoc.getElementsByTagName("heroImg").item(0);
        theHero.src = incomingString;
    }
}
于 2016-02-14T18:35:44.690 回答
0

尝试设置属性

theHero.setAttribute('src', incomingString)
于 2016-02-16T01:59:41.970 回答