Customizing SMF > Graphics and Templates
Trouble adding jquery
NBK*Twitch:
So I am trying to add a simple jquery script to a theme I am working on. Problem is I keep getting a php error.
It is probably due to the ' marks used in the jquery.
Here is the code giving an issue -
--- Code: ---
<script>
$(function () {
var msie6 = $.browser == 'msie' && $.browser.version < 7;
if (!msie6) {
var top = $('# main_menu ').offset().top - parseFloat($('# main_menu').css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('#main_menu').addClass('fixed');
} else {
// otherwise remove it
$('# main_menu ').removeClass('fixed');
}
});
}
});
</script>
--- End code ---
If you need any more information just ask :).
mashby:
What is the php error? If it's indeed the ', just escape it, or use " instead. And instead of just <script>, it should be:
--- Code: ---<script type="text/javascript">
--- End code ---
NBK*Twitch:
--- Quote from: mashby on July 15, 2012, 11:13:53 PM ---What is the php error? If it's indeed the ', just escape it, or use " instead. And instead of just <script>, it should be:
--- Code: ---<script type="text/javascript">
--- End code ---
--- End quote ---
The error is -
--- Code: ---Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in .../Themes/****/index.template.php on line 141
--- End code ---
mashby:
And what's line 141?
NBK*Twitch:
--- Quote from: mashby on July 15, 2012, 11:25:07 PM ---And what's line 141?
--- End quote ---
--- Code: --- var msie6 = $.browser == 'msie' && $.browser.version < 7;
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version