Why does firefox (not tested in another browser) have problems loading form values when it #;is in the address bar? If I have <input type='radio' checked="checked">, the presence of this element in the address bar can lead to the fact that the input will not be verified (as expected)
#;
<input type='radio' checked="checked">
How can I avoid this behavior?
Code example:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" style="min-height:100%;"> <head> <title>stuff2test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body class="popup" > <form action="" id="frm"> <a href="#;" onClick="alert('added');">add #; to addressbar, and refresh</a> <?php $rnd = mt_rand(1, 4); ?> <label for="r_v1"> <input id="r_v1" type="radio" value="v1" <?php if($rnd==1){ echo 'checked="checked"';}?> name="r"></input> checked?</label> <label for="r_v2"> <input id="r_v2" type="radio" value="v2" <?php if($rnd==2){ echo 'checked="checked"';}?> name="r"></input> checked?</label> <label for="r_v3"> <input id="r_v3" type="radio" value="v3" <?php if($rnd==3){ echo 'checked="checked"';}?> name="r"></input> checked?</label> </form> <button onClick="getElementById('frm').submit();" type="button">submit</button> <br/> RND: <?php echo $rnd;?> <?php if($rnd>0 && $rnd<=3){ echo "Checkbox {$rnd} should be checked"; } ?> <br/> <?php var_dump($_GET); ?> </body> </html>
Edit2: cleared the code a bit, added an echo
From reading the comments on the question, the answer seems clear.
, Firefox , , , . , , HTML , Firefox , HTML, , .
, , HTTP- Cache-Control: no-store autocomplete="off" . . Javascript reset ( reset(), ).
Cache-Control: no-store
autocomplete="off"
reset()
, ?
<a href="#">link</a>
- JavaScript (: jQuery ), ?
$('a').click(function() { alert(1); });
return false .
return false
$('a').click(function() { alert(1); return false; });
Edit:
... JavaScript!
, - ? , ID - ... , ...
$('a.my_class').click(function() { // $('a#my_id') // All you need to do. return false; // For preventing browser to add '#' after current link (if you have 'href="#"'). });
(#) URL-. , , , , URL-, POST ( AJAX- URL-, GET ) .
- Google _ escaped_fragment_, , URL- .
I use this "trick" in bulk and have no problem because I use the input type = "submit" control.
If you replace the line:
<button onClick="getElementById('frm').submit();" type="button">submit</button>
with
<input type="submit" value="submit" />
solve the problem without changing the anchors and not touch the javascript code.
Good luck