ADBlock is blocking some content on the site

ADBlock errore

return hit in form pagerefresh can't be blocked

StackOverflow https://stackoverflow.com/questions/14276238


I'm trying to prevent my page from refreshing after i hit return in my textfield:

<input onkeyup="keyPressCodetitle(event, false, false, 0, 6, 20);" class="form_field" id="codeTitle" type="text" name="codename">

But somehow the keyPressCodetitle function will not prevent this even with the (as far as i know) neccesary requirements to stop it from refreshing the page. (It is however showing alerts etc. in the if statement accordingly. So the function and if are working properly)

Am i missing something perhaps?

function keyPressCodetitle (e, caseBoolean, isFragment, generalCode, sourceId, projectId, method) {
    //Get the key entered via onpress(Which for firefox)
    var keycode = (e.keyCode ? e.keyCode : e.which);
    if(keycode == '13'){
        //Functioncall here
    } else {
        //other function here when not pressing return  
    return false;

Thanks in advance,

No correct solution


It's not that "[Return] makes the page refresh"; It's that some (many?) browsers, by default, will treat a [Return] in text inputs as a sign of form submit-ion.

And that seems to happen on key down, so preventing this upon key up is, too late.

Add an extra listener to onkeydown may help:

<input onkeydown="preventSubmit(event);" onkeyup="keyPressCodeTitle(event);" />

JSFiddle demo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow