Sign in to follow this  
walkingcarcass

[web] Buttons corrupt the address bar! Help!

Recommended Posts

I was using <input type="button" value="label" onclick="javascript:xxx" /> to launch javascript events in my page. It struck me that a better idea would be <button onclick="javascript:xxx">label</button> since the inputs didn't really belong to a form, and the proper buttons can be CSS'd. There was one odd difference, though. When any button was clicked, now the address bar fills up with ?name=value&name=value... for all inputs on the page. Why should this happen and how do I stop it?

Share this post


Link to post
Share on other sites
Appearantly the browser is trying to submit a 'form', using a get-request.
I've tested it out, and it work fine in Explorer and FirefoxSo I have no idea what's going on.
But why not just use the input? Works in every browser and you can assign a css class to it or use the style attribute just fine.

Share this post


Link to post
Share on other sites
Well, AFAIK inputs of type button can't contain other HTML such as images, and i'd have to type 'class="but"' or something for each of many buttons and I'd rather have a button{} entry in the .css.

It may well end up being the workable solution, but I'd still like to know why it's happening. They're not submit inputs.

Share this post


Link to post
Share on other sites
Do you have any form tags lingering around on your page? Buttons often become a default form submit widget. And else try:

<button onclick="javascript:xxx; return false;">Label</button>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this