【问题标题】:How to update HTML object data and type through Javascript in Safari?如何在 Safari 中通过 Javascript 更新 HTML 对象数据和类型?
【发布时间】:2011-12-04 13:31:49
【问题描述】:

我已经使用以下代码在 HTML 中声明了一个对象:

<object type="text/plain" id="clueBox" data="clues/random.txt" height="315" width="560"></object>

然后在我的 Javascript 中,我有一个如下所示的函数:

function dummy(){
    var box = document.getElementById("clueBox");

    //alert(currentClue + " " + clueTypes[clueNum]);
    box.setAttribute("type", "text/plain");
    box.setAttribute("data", "clues/clue0.txt");
    alert("Called Dummy");

}

调用此函数应该会更新 HTML 中的线索框对象。它在 Firefox 中完美运行,但在 Safari 中根本无法运行。我需要让它在 Safari 中工作。有谁知道我该怎么做?

【问题讨论】:

  • 你如何/在哪里调用函数?

标签: javascript safari html


【解决方案1】:

您的代码没有问题。我会在 Safari 中检查您的错误控制台,看看是否有 javascript 错误。您可以通过按 Ctrl+Alt+C 打开它。你的警报也被触发了吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-11
    • 2021-09-24
    • 1970-01-01
    • 1970-01-01
    • 2016-06-25
    • 1970-01-01
    • 2020-11-18
    • 1970-01-01
    相关资源
    最近更新 更多