Strangely, if I do <a href=“c:\foo\spa.html”>Home</a> I get a link that works just fine. It’s a workaround, but I’m irritated by the fact that I can’t get the button to work.
For a FORM to work correctly the Action attribute must refer to a CGI action. What you are attempting to do is use a FORM as an ordinary link. Of course it won’t work because it is not a CGI action.
According to W3C standards, “action - This attribute specifies a form processing agent. User agent behavior for a value other than an HTTP URI is undefined.”
Source: http://www.w3.org/TR/html401/interact/forms.html#h-17.3
BTW, you are using an absolute path in your example. Better to use a relative path. Ideally, web pages, or even a complete web site, should be portable enough that you could move it lock, stock and barrel from one server to another with mininal to no tweaking.
You could always just download a button (or make one yourself) from one of those free web gear sites. I’m sure they have buttons which look like the square, grey Windows ones, if that’s what you’re after (hell, you can have a Hello Kitty one if you like).
So if we call it “button.gif”, then you can have:
<a href=“c:\foo\spa.html”><img=“button.gif” BORDER=0></a>
I think Fenris was mostly correct (it need not be exclusively CGI), but this sort of tricks the browser into doing what you want it to do…You could also take a snapshot of a button and make it an image and use that as a link.
Wrong. CGI has nothing to do with it. Here’s an example of a form which gets submitted to a non-CGI url: http://www.codsquad.com/~galt/buttonlink.html
The problem is that “LINK” is not a valid form method. Your choices are GET and POST. “GET” is a link. When you submit a GET form, the form contents are appended as arguments to the action URL specified in the form, and the browser is sent to that URL. So really, all you have to do is change your form’s method to GET.
Snetho, I think you’re right. I have used forms in the past, and they weren’t anything to do with CGI (they are better with CGI though). I’m just wondering if a form will work for a simple link button. Might be overkill. It would remove the problem of having to provide a graphic though, as it is automatically rendered by the browser. I’m still inclined to go with the simple <a> tags.
Also, Duckster is right about the relative addressing. Just call it “spa.html” and it’ll be easier to work with.
What’s to wonder about? It works. Overkill, schmoverkill. It’s not like using a form takes up a significant amount of resources or extra work. If you want the thing to look like a button, it’s a whole lot more sensible to use a real button than it is to fake it with pictures of buttons (because if you fake it, it’s much more work to get the correct button behavior (i.e. pushing in when you click, etc), and it’s more work to get it to look right on varying platforms).
That button actually changes the content of another frame, but is easily modified for whatever purpose. This is slightly less code than using form tags, especially if you want multiple buttons on a page linking to multiple pages. The drawback of this is that it may not work on browser’s with javascript diabled.
I think saying “Hey, just use javascript and your problem is solved” overlooks the fact that not a lot of beginners know a darn thing about javascript.
Suggesting javascript: reasonable idea
Assuming javascript is easier than HTML: wrong idea
I think the top.xxx refers to a frame. I think location.href will work just fine.
<input type=“button” value=“Home” OnClick=“location.href=‘c:\foo\spa.html’”>
Sorry, I guess it is just a matter of how you go about learning something. I copy and pasted javascript from websites long before I knew how to do anything with it.
The absolute best way to learn HTML, if you are teaching yourself, is to view the source of other people’s webpages (though I must say this sort of a button is pretty rare) with a combo of a reference book to look at when you are stumped. I thought this was a good book, though I moved on to something else now.
When you hand-code this there’s some things you never forget! (well, ok, I just hand-formatted it and drew some pics, someone else had done the transcription, and yeah, I’m still not done with the damn thing).
But still, setting up a forwarding/redirect form with CGI is pretty difficult in its own right, especially if you are trying to test it out on your own machine. It is actually kind of surprising that what you suggest isn’t easier to code.
METHOD=LINK isn’t valid as far as I know, but it’s funny that the HTML Goodies site uses it, as well as several other sites. Actually, you don’t need a METHOD at all, so putting in a METHOD of LINK or GET or MYMOTHERWEARSCOMBATBOOTS won’t make any difference, the button will still work.
Also, you do need JavaScript. OnClick is a JavaScript event handler.