I use the following code to allow users to add a bookmarklet to browsers, which works perfectly, but if I try actually firing the code from a link on a page it does not.
Is there something different I need to add/subtract from the code.
Here's what i use:
javascript:(function(d){
var%20modal=document.createElement('iframe');
modal.setAttribute('src','http://url.com/bm.html?
url='+encodeURIComponent(window.location.href)+'&page_title='+document.title);
modal.setAttribute('scrolling','no');
modal.setAttribute('name','my_modal');
modal.className='modal';
document.body.appendChild(modal);
var%20c=document.createElement('link');
c.type='text/css';
c.rel='stylesheet';
c.href='//iframe.css';
document.body.appendChild(c);}(document));
I tried the following but doesn't work:
<a href="#" onclick="javascript:(function(d){var%20modal=document.createElement('iframe');modal.setAttribute('src','http://url.com/bm.html?url='+encodeURIComponent(window.location.href)+'&page_title='+document.title);modal.setAttribute('scrolling','no');modal.setAttribute('name','my_modal');modal.className='modal';document.body.appendChild(modal);var%20c=document.createElement('link');c.type='text/css';c.rel='stylesheet';c.href='//iframe.css';document.body.appendChild(c);}(document));">test</a>