0

I've created a bookmarklet some time ago and now i am trying to add the ability to login.

The way i do it. is if the user currently isn't logged in and clicked on the bookmarklet a popup window opens with the url of my login page.

my idea was once a user logged in i will echo a javascript script tags. within the script there is a call to function that is defined in the bookmarklet.

I echo this in the popup once a user is logged.

if(logged){
    echo '
    <script type="text/javascript">
        window.opener.updateLoginBookMarklet(true);
        window.close();
    </script>
   ';
    exit;
}

This is the function that's defined in the bookmarklet:

window.updateLoginBookMarklet = function(status){
     LoggedIn = status;
}

however its seems that i get Error: Permission denied to access property "updateLoginBookMarklet"

It might be due to cross domain issue i am not sure.

anyone has a clue ? is there a way around it ?

Neta Meta
  • 4,001
  • 9
  • 42
  • 67

1 Answers1

0

It might be due to cross domain issue i am not sure.

You are correct. JavaScript in a page from one domain can not directly interact with a page from another domain, for security reasons.

One solution is to use addEventListener and postMessage. I suggest reading about these first and then Googling bookmarklet postmessage for some practical examples.

DG.
  • 3,417
  • 2
  • 23
  • 28