这是我获取网址的方法:
tell application "Safari"
set _URL to URL of current tab of front window
end tell
对于成功打开的页面,我得到了正确的URL。但是对于那些无法打开的用户,其选项卡名称为“ Failed to open page”(无法打开页面),页面内容为“ Safari无法找到服务器”,则该URL并非真实的网站地址。
我得到的是:
文件:///Applications/Safari.app/Contents/Resources/
那么,当页面无法打开时,我如何获得Safari地址栏中的真正信息?
您可能仍然可以使用UI脚本从物理上获取地址字段中的文本。
tell application "Safari" to activate
delay 0.1
tell application "System Events"
tell process "Safari"
key code 37 using {command down}
key code 8 using {command down}
delay 0.1
key code 53
end tell
end tell
set _URL to the clipboard
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句