Passing HTML form data in the URL on local machine (file://)
I'm building a small HTML/JS application for primary use on local machine (i.e. everything is accessed via file://
protocol, though maybe in the future it will be hosted on a server within intranet).
I'm trying to make a form with method="get"
and action="target.html"
, in the hope that the browser will put form data in the URL (like, file://<path>/target.html?param1=aaa¶m2=bbb
). However, it's not happening (target.html opens fine, but no parameters is passed).
What am I doing wrong? Is it possible to use forms over file://
at all? I开发者_如何学编程 can always build the url manually (via JS), but being lazy I'd prefer the browser do it for me. ;)
Here is my sample form:
<form name='config' action="test_form.html" method="get" enctype="application/x-www-form-urlencoded">
<input type="text" name="param1">
<input type="text" name="param2">
<input type="submit" value="Go">
</form>
It might be some browser specific restriction. What browser are you using?
I tested this in Firefox 3.6.3 and Internet Explorer 8, and it works just fine.
Ok, that was stupid. The controls of my form are generated dynamically (via JS), and the generation function was setting id
s for them, but not name
s. So, from the form
's point of view, there was no parameters at all.
Thanks to Guffa for providing me a nudge in the right direction!
精彩评论