javascript - 使用 JavaScript document.getElementById 方法的结果“缺失值”
问题描述
我正在尝试自动化搜索并关注计算机在搜索栏中搜索的部分。我认为我所有的语法都是正确的,但是当我运行代码时,什么也没有发生,并且在 applescript 结果日志中它说“缺少值”..
这是我的代码:
to inputByID(theId, theValue) --defines the function--
tell application "Google Chrome"
open location "https://www.google.com "
execute javascript " document.getElementById(' " & theId & " ').value = ' " & theValue
end tell
end inputByID
inputByID("lst-ib", "hi ")
我的语法错误还是我遗漏了什么?任何帮助表示赞赏..
解决方案
" document.getElementById('" & theId & "').value = '" & theValue & "'"
可能你必须删除前后的空格theId
这样它就变成('myId')
了(' myId ')
并在末尾添加报价。
推荐阅读
- php - 从一个控制器 Laravel PHP 对两个表进行操作的最佳实践
- python - great_expectations 和scrapy
- javascript - jquery中的目标按钮类
- ajax - 使用 Vue 和 Laravel 存储 AJAX 搜索结果
- android - 如何使用导航组件实现此导航图?
- haskell - Haskell 泛型。构建代表
- flutter - 无法从 FirebaseMessaging 消息映射中提取数据
- excel - 使用脚本将excel行复制到特定的单词文本框中
- javascript - 如何等待来自 golang wasm 的 js 异步函数?
- directory - 如何在哈巴狗中使用绝对路径?