Firefox는 selected = "selected"옵션을 무시합니다.
드롭 다운을 변경하고 페이지를 새로 고치면 Firefox가 선택한 속성을 무시하는 것처럼 보입니다.
<option selected="selected" value="Test">Test</option>
실제로 이전에 선택한 옵션이 선택됩니다 (새로 고침 전). 다른 것을 변경하는 드롭 다운에서 트리거되는 이벤트가 있기 때문에 이것은 결국 저에게 문제가됩니다. (페이지가로드 될 때 다른 이벤트를 발생시키는 것 외에) 파이어 폭스가이 동작을 멈추게하는 방법이 있습니까?
AFAIK,이 동작은 Firefox에 하드 코딩됩니다.
defaultValue
페이지로드시 각 양식 요소를 설정할 수 있습니다.
autocomplete="off"
모든 선택 태그에 HTML 속성을 추가 하십시오. (출처 : https://stackoverflow.com/a/8258154/260080 )
이것은 FireFox의 ODD 동작을 수정합니다.
파이어 폭스에서는 폼에 이름 속성이있는 폼 안에 select를 배치하지 않으면 "selected"속성이 작동하지 않는다는 것을 알았습니다.
방금 같은 문제가 발생했습니다.이 멍청한 파이어 폭스 동작으로 10 시간 이상 고생했습니다. 저는 7 개의 드롭 다운이 있습니다. 각 드롭 다운은 이벤트를 트리거하고 24 개의 숨겨진 입력을 채울 것입니다. 따라서 올바른 옵션을 선택하는 것을 상상할 수 있습니다. 24 개의 잘못된 입력 값 !!! 내가 마침내 찾은 해결책은 다음 코드 줄을 추가하는 Javascript로 양식을 재설정하는 것입니다.
window.onload = function() { document.forms['MarkerForm'].reset(); };
추신 : 입력에는 데이터베이스에서 가져온 값이 있으므로 양식을 재설정하면 값이 비어 있지 않지만 어떤 방식으로 파이어 폭스에게 selected = selected 옵션으로 돌아가라고 지시합니다!
새로 고칠 때 이전 선택을 기억하는 것은 Firefox입니다. 대신 강제 새로 고침을 시도하세요.
또한 여기에 동일한 문제 : https://stackoverflow.com/a/1505693/1069232
또한 여기를 참조하십시오 : https://bugzilla.mozilla.org/show_bug.cgi?id=274795
FF 25.0.1을 사용하고 있습니다.
무시 selected=""
하고 selected="selected"
.
그러나 단순히 시도 selected
하면 옵션이 선택됩니다.
이상한 (비 순응적인) 동작. selected
유효한 HTML5이고 가장 짧은 형식이라는 것을 알고 있지만 일반적으로 올바른 형식의 XML을 확인하는 코드를 작성하므로 모든 XML 유효성 검사 도구를 사용하여 매우 엄격한 방식으로 결과를 확인할 수 있습니다 (데이터 교환이 매우 쉽습니다 .. .)
W3C에 따르면 이러한 변형은 부울 속성에서 유효해야합니다.
HTML5: boolAttr="" | boolAttr="boolAttr" | boolAttr
XHTML5: boolAttr="" | boolAttr="boolAttr"
마지막 (xml 준수가 아님) 변형만큼 짧지 만 XHTML5 및 HTML5 모두 유효성을 검사해야하기 때문에 첫 번째를 선호합니다. 그래서 나는 Mozilla가 그것을 고칠 것입니다!
.attr () 대신 .prop () 사용
This does not work in firefox.
$( 'option[value="myVal"]' ).attr( 'selected', 'selected' );
use this one
$( 'option[value="myVal"]' ).prop( 'selected', 'selected' );
In other way
$( this ).prop( 'selected', 'selected' );
.reset()
페이지를 새로 고치기 전에 양식을 호출 할 수 있습니다.
이름으로 더 나은 = >>
form id="UMForm" name="UMForm" class="form"
선택은 선택한 속성을 사용합니다.
Mozilla의 버그 일 수 있지만 드롭 다운에 이름을 지정해보세요.
선택을 양식 속성으로 묶으면 작동합니다.
<!-- will not work in firefox -->
<option selected="selected" value="Test">Test</option>
과
<!-- this will work in firefox -->
<form>
<option selected="selected" value="Test">Test</option>
</form>
자동 완성 기능도 작동하지 않았습니다.
이것은 내가 사용하는 jquery로 작성된 javscript 수정입니다.
$('input[type="radio"][selected]').click();
<option selected="selected" value="Test">Test</option>
이 경우 이것은 Chrome과 Firefox 모두에서 작동했습니다.
$('option[value="Test"]').prop('selected', true);
나는 .attr()
대신 사용하고 있었다.prop()
드롭 다운의 첫 번째 항목을 표시하려면 ProjectName.ClearSelection();
모든 브라우저에서 작동하도록 디자인 페이지에 줄을 배치하고 페이지로드시 코드 뒤에이 코드를 추가합니다.
$(document).ready(function () {
$("#content_ProjectName option[value='1']").prop("selected", true);
});
나를 위해 작품 autocomplete="off"
내부에 배치 하지도 않습니다 form
.
What worked was to only use the attribute selected with no "value" like this:
<option @(Model.Source == TermSource.Instagram ? "selected" : "")>
Instagram
</option>
<option @(Model.Source == TermSource.Facebook ? "selected" : "")>
Facebook
</option>
so either it renders <option selected>...</option>
, or just <option>...</option>
Try to disable autocomplete
attribute of select input ... sometimes browser ignore select
because of that
If you change the select and refresh the page firefox will restore your changes on the form, that's why you feel like the select isn't working. Instead of refreshing, try opening the link on a new tab.
This is my solution:
var select = document.getElementById('my_select');
for(var i=0; i < select.options.length; i++){
select.options[i].selected = select.options[i].attributes.selected != undefined;
}
I just put that at the top of the page (with appropriate id set), and it works for me. Replacing the getElementById with a loop over all selects on the page, I leave as an exercise for the reader ;).
For me none of the solutions above worked. I had to explicitly set the selection if none was set:
if (foo.find(':selected').length === 0) {
$(foo.find('option')[0]).attr('selected', 'selected');
}
I wish firefox would fix this :(
At work, I just fixed a bug where the select box option displayed properly in Chrome but not in Firefox, on the same web page. It turned out to be something completely different than the problems above, but could possibly be a problem you are experiencing.
In Chrome, the select box font-color was black. For some reason in Firefox, the select box inherited the font-color from the container, which was white. Once I added a CSS rule to force that select box font-color to be black, the value set was properly displayed.
참고URL : https://stackoverflow.com/questions/4831848/firefox-ignores-option-selected-selected
'program tip' 카테고리의 다른 글
Android의 비트 맵에서 원형 영역 자르기 (0) | 2020.08.14 |
---|---|
내가 사용하는 Fedora 버전을 어떻게 찾을 수 있습니까? (0) | 2020.08.14 |
Pandas는 데이터 프레임을 튜플 배열로 변환합니다. (0) | 2020.08.14 |
iframe에서 스크롤바 제거 (0) | 2020.08.14 |
기본 인증이있는 경우 Node.js에서 http.client를 사용하는 방법 (0) | 2020.08.14 |