The idea is to write a simple bookmarklet.
If the question is a possible duplicate kindly point me to it, because i was unsuccessful in finding.
I’m trying to make the current page jquery enabled using the bookmarklet and use certain jquery apis.
Uncaught SyntaxError: Unexpected token ILLEGAL
The above it the error I get using the below sample bookmarklet
javascript:(function(){
var d=document.createElement('script');
d.setAttribute('src', 'http://code.jquery.com/jquery-latest.js');
document.head.appendChild(d);
$('a').each(function(){
alert( $(this).attr('src') );
});
})()
If I execute the same code line-by-line in console it works.
Thanks in advance
To make the page wait until jQuery is fully loaded, add a load handler to the
scriptelement. This worked in my browser:I changed your code a little bit (add the
srcattribute directly as property to the createdscriptelement, retrieve theheadelement in a more classical way, useconsole.loginstead ofalertand log thehrefattribute of all links).