开发者

Google Docs Bookmarklet causes error message

I've found that if you try alter the Google Docs word editor by adding custom scripts it causes an error the moment text wraps onto a new line开发者_Python百科 or if you hit enter.

The issue can be repeated by including any script or css into the dom (example below). I've tried it in Firefox 3.6 and Safari. The error occurs even if the js file is empty.

This seriously impedes the ability to add bookmarklets to Google docs has anyone got any ideas how to avoid it? ... or is it just me?

javascript:d=document,e=d.createElement('script');e.src='http://www.domain.org/dummy.js';void(d.body.appendChild(e));


I haven't been able to reproduce the problem as specified - injecting scripts works for me. I wonder though if Google Docs cares about the DOM to the extent that the unexpected additional DOM elements are somehow messing with it?

One Idea would be to append the script/style to <head> rather than the document body like so:

javascript:(function(d,s){s=d.createElement('script');s.src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';d.getElementsByTagName('head')[0].appendChild(s);})(document)

Hope this helps!


Google docs has minified script, which means that your variables set are used also in the running of google docs, which means that google docs is trying to run while variables are messed up. Use longer variable names, so that the variables don't overlap (use words for variables)

I realize this might be 12 years late though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜