L
L
Ly2016-07-21 19:57:00
JavaScript
Ly, 2016-07-21 19:57:00

Why is the code not executing in Firefox?

There is a function:

function site(url) { 	

event.preventDefault(); 

if (typeof url == 'undefined') var url = $('#url').val();

$.post("site.php", { url: url}, function(data){ $("#site").html(data); });

}

I invoke it with:
<a href=""  class="button" onclick="site('url')">text</a>

Or:
<form method="POST" action="javascript:void(null);" onsubmit="site()">
<input id="url" name="url" value="" type="text" autocomplete="off">
</form>


In Opera, Chrome, MS Edge works as it should. Firefox simply refreshes the page, and when called via input, nothing happens at all.

I've only been learning JS for a couple of months, so I don't know the 'chips' of compatibility.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ridz, 2016-07-21
@LyoSU

everywhere add event
function site(event,url)
onclick="site(event,'url')"
onsubmit="site(event)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question