开发者

Decoupling HTML from JavaScript in bookmarklet

(Can't think of a good title :(( )

Hey all,

I'm developing a bookmarklet. When clicked 开发者_运维知识库on it creates a toolbar on the page the user is looking at. The above involves pulling various javascript and css files from my server and injecting them into the pages DOM.

I don't want to encode toolbar's HTML as a string inside one of my javascripts. So I've tried using hidden iframes to load my toolbar and then grabbing a fragment of html to insert, but immediately ran into cross-domain issues.

One solution spring to mind is sending my toolbar's html in JSON, but that seems a bit "hacky"?

What would be a good solution to the problem avoiding difficult-to-maintain html strings in javascript?

Thanks.


Don't know if it will help, here are 2 examples of toolbar bookmarklets:

  1. diigolet : www.diigo.com/tools/diigolet
  2. fytch it : fytch.com/about/get-started
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜