AppleScript : Safari page fully loaded / Dialog in full screen windows
<p>I try with so much snipped but cannot get my script to wait for safari (9.0.1) to full loaded the web page I want.</p>

<p>Any idea which works with OSX 10.11 / Safari 9.0.1 ?</p>

<p>Also, at the moment I have a really simple dialogue for timing "is safari fully loaded?"</p>

<p>However I have my Safari open in a full screen, and so the dialog will popup on the main desktop screen instead.</p>

<p>Can I not focus the dialog to wherever safari is?</p>

<pre><code>set infotosearch to the clipboard

if infotosearch is equal to missing value then
    --do nothing
else
    tell application "Safari"

        tell window 1 of application "Safari" to set current tab to tab 1
        -- Last Name
        do JavaScript "document.getElementsByName('11111')[0].value=" &amp; quoted form of infotosearch &amp; "" in document 1
        -- search
        delay 0.1
        do JavaScript "document.getElementsByName('111112')[0].click();" in document 1
    end tell
end if

-- FOCUS ON SAFARI 

tell application "System Events"
    tell process "Safari"
        set frontmost to true
        delay 1
    end tell

end tell
-- END FOCUS 

-- Dialog as cannot wait for safari page fully loaded

display dialog "Is MZ Fully loaded?" buttons {"Yes", "NO"} default button 2
if the button returned of the result is "" then
    -- nothing
else
    -- nothing
end if
</code></pre>