简体   繁体   English

在引导模式下自定义Google搜索,在相同模式下打开结果

[英]Custom Google Search in bootstrap modal, open results in same modal

I have this modal window: 我有这个模态窗口:

 .reset-box-sizing, .reset-box-sizing *, .reset-box-sizing *:before, .reset-box-sizing *:after, .gsc-inline-block { -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box; } input.gsc-input, .gsc-input-box, .gsc-input-box-hover, .gsc-input-box-focus, .gsc-search-button { box-sizing: content-box; line-height: normal; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> <!-- Search Modal --> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Search</h4> </div> <div class="modal-body"> <script> (function() { var cx = '008143018313713111535:r1f77umm7kk'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = 'https://cse.google.com/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script> <gcse:searchbox></gcse:searchbox> <hr /> <gcse:searchresults></gcse:searchresults> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> 

Which is a search window for a Google Custom Search. 这是Google自定义搜索的搜索窗口。 The search box renders fine, but the results open in a second modal, instead of opening below the search box. 搜索框呈现良好,但结果以第二个模式打开,而不是在搜索框下方打开。 How can I force GCSE to open results in the current modal? 如何强制GCSE在当前模式下打开结果?

So I thought I solved the issue when I saw that removing the script from the html here in this jsFiddle did the trick, however even if I load the script via ScriptManager in my ASP.NET application, the results always open in a separate modal. 因此,当我看到从此jsFiddle中的html删除脚本可以解决问题时,我想解决了这个问题,但是即使我通过ScriptManager在ASP.NET应用程序中加载脚本,结果也始终以单独的模式打开。

It should be noted that the modal is contained in a div to fade it in and out: 应该注意的是,该模态包含在div中以使其淡入和淡出:

<div id="modalSearch" class="modal fade" role="dialog">

which I omitted above. 我在上面省略了。 Could that make a difference? 会有所作为吗?

I had the same issue, and the I realized that you can customize how it displays, you need to go to your control panel of CSE and in the side bar, below the configuration option, it should be the option of design or layout 我遇到了同样的问题,我意识到您可以自定义其显示方式,您需要转到CSE的控制面板,并在侧栏中的配置选项下方,它应该是设计或布局的选项

Goolge CSE的外观和布局

Well, apparently I resolved my issue by moving the script out of the modal, which does make sense. 好吧,显然我通过将脚本移出模态解决了我的问题,这确实是有道理的。

Hopefully this will some some people headaches. 希望这会使一些人头疼。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM