English 中文(简体)
自动在网页上以javascript的形式提交投入
原标题:Automatically submit input on page open with javascript

我有这部法律。

var file = getUrlVars()["file"];
    if(file){
            document.getElementById( search ).value = file; 
    }
    function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}

It reads the parameter file from url and then puts the value in the search field. The search field is ajax powered, when a user enters a letter it starts searching and outputs results. The problem is that when the scripts puts the value in the search field nothing happens, how do i make the search to fire up?

这是我的搜索领域。

<input type="text" id="search" class= search_input  />

UPDATE: My Ajax search code is this

// Search
$(document).ready(function()
    {
        $(".search_input").focus();
        $(".search_input").keyup(function() 
    { 
    var search_input = $(this).val();
    var keyword= encodeURIComponent(search_input); 
    var yt_url= http://domain.com/search.php?q= +keyword;  
    $.ajax({
        type: "GET",
        url: yt_url,

        success: function(response)
    {
        $("#result").html(  );
        if(response.length)
        { 
            $("#result").append(response); 
        }
        else
        {
            $("#result").html("<div id= no >No results</div>");
        }
    }   

    }); 
    });
}   ); 
最佳回答

如果启动使非洲宇宙航空研究开发机构功能合法化的活动,那么你只能“fire<>。 因此,你需要触发这一事件。 我的野心是,这次活动必然要:

 - keyup
 - click
 - blur

你登出了相关法典,但这应当足以回答。


www.un.org/spanish/ecosoc 更新后<>

快速解决办法是启动<代码>keyup 搜索领域的活动:

$(".search_input").keyup(function() { ... }).keyup();

或者,你可以重新制定法典:

function searchlogic() { ... };

$(".search_input").keyup(searchlogic);

searchlogic();
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!