开发者

Changing a form's action attribute in IE?

开发者 https://www.devze.com 2022-12-27 06:06 出处:网络
I\'m trying to set a hash value in a form\'s action, to keep it when the form is submitted. Firefox allows me to update the hash and redirects accordingly, but IE doesn\'t. I initially though开发者_

I'm trying to set a hash value in a form's action, to keep it when the form is submitted.

Firefox allows me to update the hash and redirects accordingly, but IE doesn't. I initially though开发者_StackOverflowt this was related to IE not allowing hash values in the action attribute at all, but it seems I can't dynamically set the action at all in IE - with a hash or not? Is that right?

I'm using the following jQuery:

$("#options-form").attr('action', '#' + hash);

To update:

<form id="options-form" action="" method="get">

(On a sidenote, this wasn't needed in Firefox, because FF appears to preserve the current hash if it was only the GET params that changed.)


Why don't you use a querystring parameter to pass a certain value to the form action page?

i.e. <form id="options-form" action="mydestination.html?specialvarname=specialvalue" method="get">

That way you can easily fetch the variable on the destination page and you don't violate or misuse anything... ?

0

精彩评论

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

关注公众号