Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1116495

    Hello,

    i found the following js to remove the scrolling in my iframe with a google map.
    Can you tell me how to put the js in the functions.php?
    I tried several ways and also replaced the $ with jQuery like you say in the Documentation

    JS

    $('.map-container')
    	.click(function(){
    			$(this).find('iframe').addClass('clicked')})
    	.mouseleave(function(){
    			$(this).find('iframe').removeClass('clicked')});

    Best,
    Dennis

    #1116780

    Hey deeennis90,

    Show us what you tried please, so we can help you fix it.

    Best regards,
    Basilis

    #1116788

    Hi Basilis,

    i copied the following code in the functions.php.

    function mapcontainer(){
    ?>
    
    <script>
    jQuery('.map-container')
    	.click(function(){
    			jQuery(this).find('iframe').addClass('clicked')})
    	.mouseleave(function(){
    			jQuery(this).find('iframe').removeClass('clicked')});
    </script>
    <?php
    }

    Unfortunately it doesn’t work.

    Best,
    Dennis

    #1117330

    Hi,

    You defined the function, but you didn’t add the hook part.

    add_action('wp_footer', 'mapcontainer');
    

    What is that script for? Where did you find it?

    Best regards,
    Ismael

    #1117613

    Hi Ismael,

    i have a google map implemented in an iframe and wrapped it in a div container:

    <div class="map-container">
    <iframe width="100%" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.de/maps/ms?msa=0&ie=UTF8&vpsrc=6&fll=49.490124,10.798531&fspn=0.013297,0.034332&st=109146043351405611748&rq=1&ev=zo&split=1&sll=48.850258,13.178101&sspn=2.754455,8.453979&q=&msid=215565028450110778478.0004aad8bd13a7b82a4a0&ll=48.810481,11.310425&spn=2.17056,3.839722&z=8&output=embed"></iframe>
    </div>

    I also use this css to activate the pointer-event only when the container is clicked:

    .map-container iframe{
    	width: 100%;
    	pointer-events: none;
    	
    }
    .map-container iframe.clicked{
    	pointer-events: auto;
    }

    Thank you for the missing part in my JS. It now seems to work as expected.

    Best,
    Dennis

    • This reply was modified 5 years, 5 months ago by deeennis90.
    #1117799

    Hi,

    Did you need additional help, or shall we close this topic?

    Best regards,
    Jordan Shannon

    #1123562

    Hi Jordan,

    thanks, you can close this topic as solved.

    Best,
    Dennis

    #1123656

    Hi,

    If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘jQuery for GoogleMap no scrolling’ is closed to new replies.