Javascript 如何使搜索按钮重定向到搜索结果页面?
我是一个初学者和新的东西,我有一个按钮类型的搜索表单提交我想当我点击该按钮打开一个新窗口,显示一个url的搜索结果。有人能帮我解答这个问题吗 php代码: 删除event.preventDefault;从处理程序中,它停止表单提交,这是表单的默认行为Javascript 如何使搜索按钮重定向到搜索结果页面?,javascript,php,jquery,url,search,Javascript,Php,Jquery,Url,Search,我是一个初学者和新的东西,我有一个按钮类型的搜索表单提交我想当我点击该按钮打开一个新窗口,显示一个url的搜索结果。有人能帮我解答这个问题吗 php代码: 删除event.preventDefault;从处理程序中,它停止表单提交,这是表单的默认行为 $( 'form[role=search] input, form[role=search] button' ).on( 'focus, click', function( event ) { // Display the
$( 'form[role=search] input, form[role=search] button' ).on( 'focus, click', function( event ) {
// Display the Full Screen Search
$( '#full-screen-search' ).addClass( 'open' );
// Focus on the Full Screen Search Input Field
$( '#full-screen-search input' ).focus();
} );
1.将target=\u blank添加到标记中。2.删除event.preventDefault;请不要使用不相关的标签,或者解释这与PHP的关系。此外,显示您打开该新窗口的尝试是否希望窗体转到action=属性中指定的地址?如果是,请删除event.preventDefault;行,它停止提交操作的默认行为。没有结果?试试这个:对我来说很好。你需要更具体一些。不工作是一个无用的问题描述;当您发送表单时,会发生什么情况?你看控制台了吗?
jQuery( document ).ready( function( $ ) {
// ... display the Full Screen search when:
// 1. The user focuses on a search field, or
// 2. The user clicks the Search button
$( 'form[role=search] input, form[role=search] button' ).on( 'focus, click', function( event ) {
// Prevent the default action
//event.preventDefault();
// Display the Full Screen Search
$( '#full-screen-search' ).addClass( 'open' );
// Focus on the Full Screen Search Input Field
$( '#full-screen-search input' ).focus();
} );
// Hide the Full Screen search when the user clicks the close button
$( '#full-screen-search button.close' ).on( 'click', function( event ) {
// Prevent the default event
event.preventDefault();
// Hide the Full Screen Search
$( '#full-screen-search' ).removeClass( 'open' );
} );
} );
$( 'form[role=search] input, form[role=search] button' ).on( 'focus, click', function( event ) {
// Display the Full Screen Search
$( '#full-screen-search' ).addClass( 'open' );
// Focus on the Full Screen Search Input Field
$( '#full-screen-search input' ).focus();
} );