当前,我有:
if (confirm("Are you sure?")) { do something }
消息显示后,用户单击“确定”,即为true
。
显示消息时,用户单击“取消”,即为false
。
如果用户选中“阻止此页面创建其他对话框”框,则确认将始终返回false
。
是否可以检查用户是否已选中“阻止此页面创建其他对话框”框?
我想做的是:
var dialogsPrevented = // boolean that depicts whether dialogs are being suppressed.
if (dialogsPrevented || confirm("Are you sure?")) { do something }
答案 0 :(得分:3)
在之前和之后检查function checkedConfirm(query) {
var time = Date.now();
var response = confirm(query);
if( response) return "TRUE";
if( Date.now() - time > 10) return "FALSE";
return "DIALOG_NOT_FOUND";
}
。除非用户在百分之一秒的时间内单击按钮,否则您可以确定对话框是否被阻止。
final String idField = "id";
final String toField = "productId";
String indexPath=".........";
try {
Directory dir = FSDirectory.open(Paths.get(indexPath));
Analyzer analyzer = new StandardAnalyzer();
IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
iwc.setOpenMode(OpenMode.CREATE);
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
doc = new Document();
doc.add(new TextField("description", "more random text", Field.Store.NO));
doc.add(new TextField("name", "name2", Field.Store.NO));
doc.add(new TextField(idField, "4", Field.Store.NO));
doc.add(new SortedDocValuesField(idField, new BytesRef("4")));
w.addDocument(doc);
w.commit();
// 4
doc = new Document();
doc.add(new TextField("price", "10.0", Field.Store.NO));
doc.add(new TextField(idField, "5", Field.Store.NO));
doc.add(new SortedDocValuesField(idField, new BytesRef("5")));
doc.add(new TextField(toField, "4", Field.Store.NO));
doc.add(new SortedDocValuesField(toField, new BytesRef("4")));
w.addDocument(doc);
IndexReader reader = DirectoryReader.open(FSDirectory.open(Paths.get(indexPath)));
IndexSearcher searcher = new IndexSearcher(reader);
w.close();
Query joinQuery =
JoinUtil.createJoinQuery(idField, false, toField, new TermQuery(new Term("name", "name2")), searcher, ScoreMode.None);
TopDocs result = searcher.search(joinQuery, 10);
System.out.println("Total Hits:"+ result.totalHits);
System.out.println("Doc1: "+ result.scoreDocs[0].doc);
System.out.println("Doc2: "+ result.scoreDocs[1].doc);
}catch(Exception e) {
e.printStackTrace();
}
根据需要/有用调整返回值。