【问题标题】:Using "Style" in a variable在变量中使用“样式”
【发布时间】:2015-09-22 05:59:03
【问题描述】:

目前,我要做的就是让这段 HTML 中的样式显示在 WScript.Echo 弹出窗口中。我找不到执行此操作的正确语法。我想要的值是:"width: 0%;"(或任何值)。

HTML:

<div class="progress" id="progress-bar-current-progress" style="width: 0%;">

这是我尝试过的一些事情(其中一些我只是在黑暗中刺伤):

wscript.echo ie.document.getElementsByTagName("div").getAttribute("style").innertext
wscript.echo ie.document.getElementsByTagName("div").getAttribute    ("style").innerhtml
wscript.echo ie.document.getElementsByTagName("div").style.width
wscript.echo ie.document.getElementsByTagName("div").style.innertext
wscript.echo ie.document.getElementsByTagName("div").style.innerhtml
wscript.echo ie.document.getElementById("progress-bar-current-progress")(1)
wscript.echo ie.document.all.item("progress-bar-current-progress").innerText
wscript.echo ie.document.all.item("progress-bar-current-progress").innerHtml
wscript.echo ie.document.all.item("progress-bar-current-progress").cssText
wscript.echo ie.document.all.item("progress-bar-current-progress").getAttribute("style")
wscript.echo ie.document.all.item("progress-bar-current-progress")(1)
wscript.echo ie.document.getElementsByTagName("div")(1)
wscript.echo ie.document.getElementsByTagName("div")(0)
wscript.echo ie.document.getElementsByTagName("div")(2)
wscript.echo ie.document.getElementsByTagName("div")(3)
wscript.echo ie.document.getElementsByTagName("div")(4)
wscript.echo ie.document.getElementsByTagName("div")(5)
wscript.echo ie.document.getElementsByTagName("div")(6)

【问题讨论】:

    标签: html css vbscript wsh


    【解决方案1】:

    这应该可行:

    style = ie.document.getElementById("progress-bar-current-progress").getAttribute("style")
    WScript.Echo style
    

    如果不需要,您需要显示您的代码以及您遇到的任何错误。

    【讨论】:

    • 回显框弹出,但是是空白的。
    • 好吧,我已经为这种情况提出了行动方案,不是吗?
    • 如果您指的是发布我的代码,我在您第一次回复后就这样做了。它没有出现 - 说它必须经过同行评审。不受我控制。它只是从文本文件导航到 URL 的基本 vbscript。同时:pastebin.com/43sphQQ7
    • 对我可以尝试的事情有什么想法吗?
    • 不要发布指向 pastebin 的链接。该代码属于您的问题。另外,HTML 的其余部分是什么样的?它是否包含框架或 iframe?如果从 VBScript 中删除 On Error Resume Next 会发生什么?
    【解决方案2】:

    你可以像这样从 jQuery 中获取样式属性值,

    var style = $("#progress-bar-current-progress").attr('style');
    

    【讨论】:

    • 如何与 vbscript 一起使用?
    猜你喜欢
    • 2019-10-20
    • 2022-10-21
    • 1970-01-01
    • 1970-01-01
    • 2018-12-24
    • 2012-05-19
    • 2018-09-27
    • 2017-10-08
    • 2018-02-09
    相关资源
    最近更新 更多