我想找到一个safari选项卡,并关注这个选项卡
这是不工作,但标签是找到正确的,我只是不能打开这个标签。
tell application "Safari"
repeat with t in tabs of windows
tell t
if name starts with "facebook" then open tab
end tell
end repeat
end tell
我也想知道我能从另一个标签中找到一些文本而不关注这个标签吗?
to getInputByClass75(theClass, num)
tell application "Safari"
set input to do JavaScript "
document.getElementsByClassName('" & theClass & "')[" & num & "].innerHTML;" in document 1
end tell
return input
end getInputByClass75
getInputByClass75("Order", 0)
set theText to Unicode text
set theSource to getInputByClass75("Order", 0)
property leftEdge75 : "<a class="columns" href="/Web"
property rightEdge75 : "">Display</a>"
set saveTID to text item delimiters
set text item delimiters to leftEdge75
set classValue to text item 2 of theSource
set text item delimiters to rightEdge75
set OrderLink to text item 1 of classValue
set text item delimiters to saveTID
OrderLink
将选项卡带到前台的正确短语是
tell window x to set current tab to tab y
试试这个
tell application "Safari"
repeat with w in windows
if name of w is not "" then --in case of zombie windows
repeat with t in tabs of w
if name of t starts with "facebook" then
tell w to set current tab to t
set index of w to 1
end if
end repeat
end if
end repeat
end tell
,
你可以在后台标签页执行javascript。像这样指定制表符:
tell application "Safari"
do JavaScript "document....." in tab 1 of window 1
end tell