I am new to bookmarklet coding and i have run into a problem where the regular javascript works fine in the browser but not the bookmarklet version.
I had found a bookmarklet which finds a image and turns it into BB code and that works fine, however it loads jQuery and i did not want it doing that all the time. So i was basically just trying to remove the need for it but now it does not work anymore as a bookmarklet.
The original bookmarklet was this:
javascript:document.body.appendChild(document.createElement('script')).src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js';var%20pictureurl=jQuery('img[id$=%22myImage%22]').attr('src');var%20linkurl=document.location.href;alert('%5BURL='+linkurl+'%5D%5BIMG%5D'+pictureurl+'%5B%2FIMG%5D%5B%2FURL%5D');
My javascript which works as regular JS code is:
// Create array variables
var imgs = [];
// Put all of the documents tags in to the arrays
imgs = document.getElementsByTagName('img');
var pictureurl = '';
var linkurl = document.location.href;
for(var i = 0; i < imgs.length; i++){
var str = imgs[i].getAttribute('id');
var find = str.search("myImage");
if(find != -1){
pictureurl = imgs[i].getAttribute('src');
alert('[URL=' + linkurl + '][IMG]' + pictureurl + '[/IMG][/URL]');
}
}
When i add javascript: and append the minimized code i can not get it working no matter what i try. If anyone could help me get this working that would be a big help, thanks.