简体   繁体   中英

Adding Bookmarklet Javascript to Block?

Hello i've been trying to do this for about 2 years. I think it worked once but ever since then i just can't make it happen again. Im adding this code to a block-

<a href="javascript:u=document.location.href;t=document.title; s=window.getSelection();
void(window.open("http://onlinebanter.com/node/add/web2ob?edit[title]="+escape(t)+'&edit[body_field][body]='+escape(s)+'&edit[field_link][0][url]='+escape(u),'_blank','width=600,height=500,status=yes,resizable=yes,scrollbars=yes'));">Test</a>

When i try to drag that to my browser the url comes out as so-

javascript:u=document.location.href;t=document.title;s=window.getSelection();void(window.open(

I am using the Full HTML filter option and isnt adding line breaks or anything. If i edit the link in my browser and add just

javascript:u=document.location.href;t=document.title;s=window.getSelection();void(window.open("http://onlinebanter.com/node/add/web2ob?edit[title]="+escape(t)+'&edit[body_field][body]='+escape(s)+'&edit[field_link][0][url]='+escape(u),'_blank','width=600,height=500,status=yes,resizable=yes,scrollbars=yes'));

Things work great. I have looked about and have asked here previously http://drupal.org/node/235074

I must just be missing something so simple as it seems the whole internet doesnt have this problem. All help appreciated thanks.

Reg`

I think the problem is with the double-quotes in your window.open() call.

The browser thinks that you're closing the href="javascript... "

Replace the double quotes in "http://onlinebanter.com/node/add/web2ob?edit[title]=" with single quotes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM