Jump to content

Mobile Logo Link and Background Colour Change

Go to solution Solved by Lesum,

Recommended Posts

Hello!

 

I'm wondering if there is a way to make my mobile logo a clickable telephone (calls a number when selected) and also change the background colour just on mobile.

I want my Desktop nav to stay the same just make these changes on mobile version.

Thanks

Link to comment

@elizamills Here's a code snippet that will link mobile logo to phone number. Add this code to Settings > Developer Tools > Code Injection > Header

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>
$(document).ready(function() {
    checkScreenSize();
    function checkScreenSize(){
        var newWindowWidth = $(window).width();
        if (newWindowWidth < 481) {
            $('.header-title-logo a').attr('href', 'tel:61401577672');
        }
    }
});
</script>

 

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Link to comment

@elizamills It didn't work because you changed your header on mobile version since the time I wrote the code.  When I wrote the code your mobile header was different (only a logo and menu bar). 

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Link to comment

@elizamills I'm seeing a phone number on top of the logo on mobile. Phone number was added with custom code. When I wrote the code, the phone number was not there. Do you still want to add a clickable telephone on the logo? 

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Link to comment

@elizamills Thanks for explaining the changes you made. Square kicker isn't causing any issue. I'll have to modify the code I written previously to make it work. I'll share the code with you shortly. 

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Link to comment
  • Solution

Here's the updated code:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>
$(document).ready(function() {
    checkScreenSize();
    function checkScreenSize(){
        var newWindowWidth = $(window).width();
        if (newWindowWidth < 481) {
            $('.header-mobile-logo a').attr('href', 'tel:0401577672');
        }
    }
});
</script>

Let me know if it works. Thanks!

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.