Execute a Javascript function for the site link?

5

Example I have the link:

www.meusite.com.br/index.php?subject=conteudo do assunto;message=teste de mensagem

I want to call the onclick function of this button automatically:

<input value="Enviar" tabindex="3" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit" type="submit">

What do I change in the link to call this click function?

Follow the function:

function submitThisOnce(oControl)
{
    // Hateful, hateful fix for Safari 1.3 beta.
    if (is_safari)
        return !smf_formSubmitted;

    // oControl might also be a form.
    var oForm = 'form' in oControl ? oControl.form : oControl;

    var aTextareas = oForm.getElementsByTagName('textarea');
    for (var i = 0, n = aTextareas.length; i < n; i++)
        aTextareas[i].readOnly = true;

    return !smf_formSubmitted;
}
    
asked by anonymous 18.09.2015 / 03:06

2 answers

3

If I understand your question, you can do this via JavaScript as follows:

function suaFuncao() {
    alert('sua função');
}

/*Pega o evento de Load da pagina*/
(function() {

    /*Pega a url atual*/
    var urlAtual = window.location.href;

    /*Seta a url para chamar a função*/
    var urlParaRedirecionar = 'www.seusite.com.br';

    /*verifica se é para execultar a função, se sim, ele a execulta*/
    if(urlAtual == urlParaRedirecionar) {
        suaFuncao();
    }

})();

To not need to compare the entire url, you can pass a parameter via url saying that it is to redirect, as in that response :)

    
18.09.2015 / 03:53
0

Let's put the complete example right, it lacked its script function there, but let's suppose it here in the answer.

<input value="Enviar" tabindex="3" onclick="submitThisOnce(this);" accesskey="s" class="button_submit" type="submit">
<script>
function submitThisOnce( $input ){
// faz alguma coisa antes do submit
}
</script>

There are those who say that the correct one is to put onclick="javascript: submitThisOnce (this);" how it works both ways I'm lazy write javascript: / p>     

18.09.2015 / 12:49