Norman
Norman

Reputation: 6365

Javascript with jQuery in between document does not work

I have a piece of javascript/jquerycode, that's executed in between the document when a page loads.

What it does, is takes the height of a particular div, and assigns it to another div.

This works perfectly well in Firefox, but fails in the latest versions of all other browsers (Chrome, Opera, Safari, IE). I'm on Windows 7 Home Premium 64 Bit.

Here's the code. It goes below a div when the page is generated. Works only in Firefox, and nothing else.

'<script type="text/javascript;">'.
    '$(document).ready(function() {'.
        '$(\'.s\').height($(\'.entry\').height());'.
    '});'.
'</script>'.

Upvotes: 0

Views: 31

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

The think the problem is the type value you have specified. You have a extra ; at the end of type attribute value.

So either change it to text/javascript or remove the type attribute entirely

type

This attribute identifies the scripting language of code embedded within a script element or referenced via the element’s src attribute. This is specified as a MIME type; examples of supported MIME types include text/javascript, text/ecmascript, application/javascript, and application/ecmascript. If this attribute is absent, the script is treated as JavaScript.

Upvotes: 1

Related Questions