JS Bookmarklet not working in IE11

long time lurker, first time poster.

The basics are:

Inspired by this blog post , I'm trying to create a bookmarklet for our QA team to quickly fill out a form.

The label works fine on my machine (TM) in the compatibility mode of Chrome, IE 10 and IE 9. I checked the bookmarklet on QA command line machines, and although it works fine on Chrome browsers and IE 9, the bookmarklet does not work on two machines with IE 11

Details:

Of the two machines running under IE 11, one is on Win 7, the other on Win 8.1. The machine running IE 11 on Win 7 has been updated to version 11.0.9600.17207IS IE, and will also correctly run the bookmarklet in Chrome.

I tried a couple of different options, the first of which is based on the CSS-Tricks blog post mentioned above.

<a href="javascript:
    (function(d) {
        var body = d.getElementsByTagName('body').item(0);
        var script = d.createElement('script');
        script.src = 'https://company.siteurl.com/unrelated/DisclosureRegister.js';
        body.appendChild(script);
    }(window.document));
    alert('Bookmarklet js fired!');">Disclosure Register Bookmarklet</a>

, qaru.site/questions/1039778/..., :

<a href="javascript:
    (function(){
        var s=document.createElement('script');
        s.type='text/javascript';    
        s.src='https://company.siteurl.com/unrelated/DisclosureRegister.js';
        document.getElementsByTagName('head')[0].appendChild(s);
    }());">Disclosure Register 2</a>

, IE 11 ( IE 11, ).

, DisclosureRegister.js . , .

"-", "" > "", javascript, , "-" ( IE 11).

<a href="javascript:alert('That tickles!');">Click me!</a>

, html Codepen, Codepen ( , ) Codepen .

-, , IE 11, IE , , .

DisclosureRegister.js -, IE 11 javascript, :

(function (win, doc, $, undefined) {

    //Don't run if jQuery isn't loaded
    if (typeof window.jQuery === 'undefined') {
        return;
    }

    alert("Script is being called!");

    }(window, window.document, window.jQuery));

:

, , (, , , , ), - IE 11 , javascript, ?

!

+4
3

. , , , .

, IE11 IE11. , , - , IE11 . , ​​ . .

, , .

, . .

+1

, IE11. IE11, , Google . - Microsoft, , . , . - IE , . , , - . .

+1

, . IE 11, -, , .

"" URL-, .

With deleting lines (I ran a regular expression to collapse all spaces to one space), after adding it to my Favorites, the properties display the correct javascript in the URL field, and it works correctly when clicked.

I could not find anything anywhere documenting this limitation.

0
source

Source: https://habr.com/ru/post/1548681/


All Articles