开发者

How do I create a "widget" for people? It's just a simple text box with my logo

开发者 https://www.devze.com 2023-01-11 14:23 出处:网络
I want something that the webmaster can copy into his site. It just needs to have my logo, a text box, and a submit button. (When the user clicks submit using that widget, it forwards to my site.)

I want something that the webmaster can copy into his site.

It just needs to have my logo, a text box, and a submit button. (When the user clicks submit using that widget, it forwards to my site.)

I know 开发者_如何转开发there are many ways to do this. What is the fastest and easiest?


I don't know about fastest and easiest, but maybe you could write a little JavaScript file that creates and injects the content into a div with a special ID.

This is along the lines of what StackOverflow does for their "flair."


Fastest way is to just put some HTML code that people can paste in their page. There's no need for buttons or form, just a simple link.

Something on the lines of:

<a href="http://www.yoursite.com/">
<img src="http://www.yoursite.com/yourlogo.jpg" alt="yoursite.com logo" title="Visit yoursite.com!" />
</a>

You'll probably want to add a couple of style tags (e.g to avoid borders around the image etc) Also, it would be easy on your site to have a little JS that changes the code above so that people can personalize it (point to different images, different sizes etc etc)


Some may frown upon it but possibly the fastest and easiest way is to use an iframe. It means that the embed code can be quite short + you can change the behaviour at a later date.

Iframe's main advantage is that you don't have to deal with the css that's already included in the page. Might not seem like a big deal but sooner or later you'll run into a page that does something with a css attribute that you just hadn't expected.

It's not pretty but it's worth considering.

0

精彩评论

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