Hi,
When I developed with Safari Extension, I could listen beforeNavigate event in global page, such as:
<!DOCTYPE html>
<head>
</head>
<body>
<script type="text/javascript" charset="utf-8">
safari.application.addEventListener("beforeNavigate", performCommand, true);
function performCommand(event) {
alert("The URL" + event.url);
}
</script>
</body>
</html>
I could receive this event, and handle it.
Working in the native app extension. A Safari App Extension doesn’t have a global HTML page. Instead, pass messages from your injected code into the app extension.
But when I develop with Safari App Extension, in the SFSafariContentScript, the similar code is not worked.
It seems the safari.application object is NULL.
if(safari.application){
safari.application.addEventListener("beforeNavigate", performCommand, true);
function performCommand(event) {
alert("The URL" + event.url);
}
}
else{
alert("no application"); ----this is alerted
}
What should I do to listen beforeNavigate event with Safari App Extension?
Thak you very much!