How to focus the tabs in Safari with AppleScript and avoid opening new

Tell application "system events".

activate an application "Safari".

key code 19 using the command to cmd - down 2 opened a second tab or activate it so open

Open the location "http://example.com".

tell the end

It works fine as long as one of them are real

1. the 2nd tab does not exist yet in this case it will be the 2nd tab and open the url in this place. Or...

2 If the 2nd tab already exists, it will launch the 2nd tab and reload the page until the 2nd tab is already at the location of Web site, we want to be.

But if you say 2 or more tabs open and you run this, if the 2nd tab the DSI not already on the url, you want it to be it will activate the 2nd tab and then open the location of the site in a new tab.

What I want is something like

Code 19 - key using the command down

Set the location of the active tab for the 1 in safari request to "http://example.com".

But this obviously doesn't work. So, how can I know Safari to use only the tabs that I said rather than open new ones every time?

Hello

To set the focus to a tab: use the "class" property of the window tab.

To open a URL: use the URL property of the tab instead of the command "open location".

As this script:

-------

set theUrl to "http://example.com".

Tell application "Safari".

otherwise (there is an active tab from the front window) and then make new document - if no window

the window before saying

If (count the tabs) = 1 then - open URL in new tab

set the active tab (to make the new tag at the end of the tabs with properties {URL: theUrl})

-2 or more tabs

the current value of the tab 2 - the second tab of the focus

the value URL of the tab current theUrl - change the URL of the second tab

end if

tell the end

tell the end

-------

Tags: iOS Developer

Similar Questions

Maybe you are looking for

  • iCloud unlocked by pc itunes how to open iphone 5s

    a locked icloud iphone connect pc. iphone and itunes update. forgotten password help to made a new call id.which id open icloud drive.and see page, settings, tone, number. now what can I do to unlocked icloud and unlock iphone 5 s.

  • Contacts shows only not as much my Mac

    Hey I have a question I recently implemented a contact for me with all of my information on her relatives etc, which gives me a total of 44 contacts until I added myself as a contact I had 43. 44 watch on my iOS devices, but 45 shows on my mac did an

  • Problem with the screen on IPAD curtain

    Hello I'm a bad psychic, and I have a problem with the screen curtain. A longitudinal of Voice Over, the screen curtain is automatically activate. Normally to turn it off, you must type three times with three fingers. Only on my IPAD when I type thre

  • I have Microsift Essentials, but do I need a registry cleaner also

    I don't know if Microsoft Essentials is also a record. I don't know a lot about the registry, but asked me to buy one after that I ran the free scan. The analysis said that I had more than 100 errors. I don't know if they are just trying to sell me s

  • Creation of DVD of Vista freezes when burning

    Vista DVD Maker freezes when burning: it was working fine before, but what I get today is "burning (E): Creating DVD, please wait... encoding..." 0.0% ' he sits there and does not activate the process of engraving as it before use. I got a google too