Question

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?

Was it helpful?

Solution

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();

OTHER TIPS

Try

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

Try to use .trigger():

$("#launcher").trigger('click');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top