0

My problem is that the Cookie Law bar won't hide... http://www.kasedesign.co.uk/scc/

The same code hides fine on other websites I've done, such as http://www.kasedesign.co.uk/spa/ I've not used this code on a Joomla website before though.

I read on here that containing the script within a Window OnLoad might help and it got rid of my error, but the cookie bar didn't hide.

Can anyone point me in the right direction?

rolve
  • 10,083
  • 4
  • 55
  • 75
user1750781
  • 1
  • 1
  • 1
  • I had this problem a while back and it was due to jQuery being call twice, so I checked that wasn't the case. Are there tools that can help me find out if jQuery is loading correctly or what conflicts might be occurring? I thought the Google Chrome Error Console would alert me to any conflicts. – user1750781 Oct 16 '12 at 17:44

2 Answers2

1

On your spa website, the file js/cookielaw.js is not called, indeed it is invoked by relative url and /spa/js/cookielaw.js return a 404 error, so no code are loaded.

On your other website (about cars), the url is absolute : /scc/js/cookielaw.js so the script is loaded.

The issue is that DOM is not ready when you call that script, so jQuery return the error.

Try to change begin of script from :

// Cookie Law
// -----------------------------------------------------------------------------

$('html').css('padding-top','35px');
$('.cookiedisclaimer').show();

(function($) {
    //...

to

// Cookie Law
// -----------------------------------------------------------------------------

(function($) {

    $('html').css('padding-top','35px');
    $('.cookiedisclaimer').show();
    //...

It's the easier and faster way to fix.

A cleaner way is to start your script like that :

// Cookie Law
// -----------------------------------------------------------------------------

$(document).ready(function() {
    $('html').css('padding-top','35px');
    $('.cookiedisclaimer').show();
}) ;

(function($) {
    //...
Cyril ALFARO
  • 1,616
  • 17
  • 35
  • Thanks for your help... I realised there is a cookie script being called that doesn't exist in the spa bathrooms site. I will address that. I tried your solutions, but they did not help. Someone mentioned earlier that a jQuery conflict may be causing my problem, but has since deleted their comment. I therefore added the following... jQuery.noConflict(); I then replaced $ for jQuery and all is working fine. Thank you to anyone that took time to look into this problem! – user1750781 Oct 16 '12 at 19:08
0

Thanks for your help... I realised there is a cookie script being called that doesn't exist in the spa bathrooms site. I will address that.

I tried your solutions, but they did not help.

Someone mentioned earlier that a jQuery conflict may be causing my problem, but has since deleted their comment.

I therefore added the following... jQuery.noConflict();

I then replaced $ for jQuery and all is working fine.

Thank you to anyone that took time to look into this problem!

user1750781
  • 1
  • 1
  • 1