Javascript 如何使搜索引擎结果不激活弹出窗口阻止程序?
乍一看,这似乎很好。但它有一个bug我想修复 如何使搜索引擎结果不激活弹出窗口阻止程序? 该功能运行良好,除了每次有人单击搜索按钮在单独的选项卡窗口中打开搜索结果时,他们需要告诉浏览器的弹出窗口阻止程序,这是正常的 如果带有代码的页面不在iframe中,它会正常工作,但当它在iframe中时,它会激活浏览器上的弹出窗口阻止程序。那么,我如何使它不激活弹出阻止程序警报或忽略浏览器中的弹出阻止程序allert,而不管它在哪个浏览器中使用 JavaScript:Javascript 如何使搜索引擎结果不激活弹出窗口阻止程序?,javascript,html,iframe,popup,popup-blocker,Javascript,Html,Iframe,Popup,Popup Blocker,乍一看,这似乎很好。但它有一个bug我想修复 如何使搜索引擎结果不激活弹出窗口阻止程序? 该功能运行良好,除了每次有人单击搜索按钮在单独的选项卡窗口中打开搜索结果时,他们需要告诉浏览器的弹出窗口阻止程序,这是正常的 如果带有代码的页面不在iframe中,它会正常工作,但当它在iframe中时,它会激活浏览器上的弹出窗口阻止程序。那么,我如何使它不激活弹出阻止程序警报或忽略浏览器中的弹出阻止程序allert,而不管它在哪个浏览器中使用 JavaScript: <script language
<script language="JavaScript">
function handleKeyPress(e)
{
var key=e.keyCode || e.which;
if (key==13){
event.preventDefault();
GoToURL();
}
return false;
}
function GoToURL()
{
var URLis;
Advance = document.URLframe.Adv.value
URLis = document.URLframe.u.value
BegEnd = document.URLframe.begnd.value
Word1 = document.URLframe.wo1.value
Code = document.URLframe.co.value
Word2 = document.URLframe.wo2.value
Lang = document.URLframe.lr.value
Country = document.URLframe.cr.value
{
var location= ("https://duckduckgo.com/?q=" + Advance + URLis + BegEnd + Word1 + Code + Word2 + BegEnd + Lang + Country + "&ia=definition");
window.open(location, '_blank');
}
}
</script>
<input type="text" name="u" size="71" value="" placeholder=" Type your Search Text here and click »» Search «« ... " id="SeekBox" onkeypress="handleKeyPress(event)">
<input type="button" id="SeekButton" onclick="GoToURL(this)" onkeypress="handle(event)" value=" »» Search «« ">
功能手柄按键(e)
{
var key=e.keyCode | | e.which;
如果(键==13){
event.preventDefault();
Gotour();
}
返回false;
}
函数gotour()
{
乌里斯变种;
Advance=document.URLframe.Adv.value
URLis=document.URLframe.u.value
BegEnd=document.URLframe.begnd.value
Word1=document.URLframe.wo1.value
代码=document.URLframe.co.value
Word2=document.URLframe.wo2.value
Lang=document.URLframe.lr.value
国家=document.URLframe.cr.value
{
变量位置=(“https://duckduckgo.com/?q=“+Advance+URLis+BegEnd+Word1+Code+Word2+BegEnd+Lang+Country+”&ia=definition“;
窗口。打开(位置“U空白”);
}
}
HTML:
<script language="JavaScript">
function handleKeyPress(e)
{
var key=e.keyCode || e.which;
if (key==13){
event.preventDefault();
GoToURL();
}
return false;
}
function GoToURL()
{
var URLis;
Advance = document.URLframe.Adv.value
URLis = document.URLframe.u.value
BegEnd = document.URLframe.begnd.value
Word1 = document.URLframe.wo1.value
Code = document.URLframe.co.value
Word2 = document.URLframe.wo2.value
Lang = document.URLframe.lr.value
Country = document.URLframe.cr.value
{
var location= ("https://duckduckgo.com/?q=" + Advance + URLis + BegEnd + Word1 + Code + Word2 + BegEnd + Lang + Country + "&ia=definition");
window.open(location, '_blank');
}
}
</script>
<input type="text" name="u" size="71" value="" placeholder=" Type your Search Text here and click »» Search «« ... " id="SeekBox" onkeypress="handleKeyPress(event)">
<input type="button" id="SeekButton" onclick="GoToURL(this)" onkeypress="handle(event)" value=" »» Search «« ">
不要在iFrame中使用绝对URL—只使用相对URL—否则它会正常工作。如果您试图将iFrame外部URL放入内部,只需在后端创建代理,这样您就可以访问同一个域。结果是在一个新窗口中,而不是在iFrame中。问题是,当我在新标签窗口中得到结果时,“弹出窗口拦截器”被激活。那么,如何将其从绝对URL更改为相对URL呢?当在一个新的选项卡窗口中获得结果时,这会解决不激活pupup阻止程序的问题吗?我需要在一个新的选项卡窗口中显示结果,这样它就不会覆盖旧页面,除非有办法获得一个新的框架选项卡页面,该页面同时调用框架页面和同一选项卡中的搜索结果的两个页面。