lundi 29 janvier 2018

javascript bookmarklet does not work on github

I have the following code on a web page. I have bookmarked it to make a bookmarklet. It works fine. I can click my bookmarklet to book mark a page (it connects to my bookmark app, on my local website).

However it does not work on github. When I click the bookmarklet, nothing happens. It should re-direct to a page on my site, with a pre-filled form.

Why does it not work on this site (github)? How can I fix it?

<a href="javascript:
(function () {
    function selectedText(){
        var t;
        try {
            t= ((window.getSelection && window.getSelection()) ||
                (document.getSelection && document.getSelection()) ||
                (document.selection &&
                 document.selection.createRange &&
                 document.selection.createRange().text));
        }
        catch(e){
            t = '';
        }
        return t;
    }

    function link() {
        return 'http://bookmarkdb/add'+
            '?url='   +encodeURIComponent(location.href)+
            '&title=' +encodeURIComponent(document.title)+
            '&description=' +encodeURIComponent(selectedText());
    }

    window.open(link());
})();
">addbookmark</a>


For full code see https://bitbucket.org/davids_dad/bookmarker




Aucun commentaire:

Enregistrer un commentaire