0

i'm trying to make a bookmarklet to change the cursor of anypage i visit.

I do this :

<a href="javascript:var i,s,ss=['http://www.zombiepanic.info/wp-content/themes/MYgRID/js/tronc.js','http://code.jquery.com/jquery-1.7.2.min.js'];for(i=0;i!=ss.length;i++){s=document.createElement('script');s.src=ss[i];document.body.appendChild(s);}void(0);"> Go! </a>

and my js file is :

(function() {

    function getCssTransform() {

        $('body').css('cursor','crosshair');

    }

getCssTransform();


})();

It's work perfectly in a empty.html page i made, but when i wan't to use in google or facebook or an other site, the script is injected but my cursor doesn't change…

Any ideas ?

(Ps : Sorry for the english, i'm french)

EDIT :

(function ($) {

$(document).ready(function() {

document.body.style.cursor="crosshair";
});

})(jQuery);

I try this, but it's the same issue.

Cat
  • 37
  • 1
  • 7
  • The pages may have their own styles that override the body style you're applying. (They also may need their own version of jQuery, so what you're doing might cause some sites not to work at all.) – Pointy May 01 '12 at 14:31

1 Answers1

0
(function(){var a=document.createElement("style");
 a.innerText="*{cursor:crosshair !important}";document.body.appendChild(a)
})()

seems to work fine. (Broken up to 3 lines for clarity.)

AKX
  • 152,115
  • 15
  • 115
  • 172
  • Yes it's work thank ! But if i want to apply a picture instead of the crosshair, it's doesn't work again. – Cat May 01 '12 at 14:39
  • You should have mentioned you'll be using an URL for it. You may be bumping into cross-domain limits -- one way around this (if that's the problem - I don't know if it is!) is to turn to `data:` urls. – AKX May 01 '12 at 14:44
  • I apply a second non-url argument to cursor. It's work perfectly ! – Cat May 01 '12 at 14:46