Pergunta

I'm trying to launch the steam client using their web protocol: https://developer.valvesoftware.com/wiki/Talk:Steam_browser_protocol

I'm using jQuery. Here is a example:

$(function() {
    // a bunch of stuff happens
    $("#content").append('<a id="launcher" href="steam://connect/' + server.ip + ':' +     server.port + '"></a>');
    $("#launcher").click();
});

Now I know this won't work... event delegation? But essentially it's what I want to do. Any ideas?

Foi útil?

Solução

You should call the native DOM's click directly

$("#launcher")[0].click();

OR

You can use .get(), it retrieves the DOM elements matched by the jQuery object and call native DOM's click directly.

$("#launcher").get(0).click();

Outras dicas

Try

$(document).on("click", "#launcher", function () {
    // code
});

Try to use .trigger():

$("#launcher").trigger('click');
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top