question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

See original GitHub issue

Hi everybody, I’m trying to add the swiper script to my web app and i’m encoutering this error :

Uncaught TypeError: Failed to execute ‘getComputedStyle’ on ‘Window’: parameter 1 is not of type ‘Element’. swiper.jquery.js:1588 s.getTranslate swiper.jquery.js:1588 s.getWrapperTranslate swiper.jquery.js:1628 s.onTouchMove swiper.jquery.js:1098

The app is developped in struts 2. Please find below the code of my jsp that fires the error :

    <div class="swiper-container">
        <div class="swipper-wrapper" id="slide"></div>
         <!-- If we need pagination -->
        <div class="swiper-pagination"></div>

        <!-- If we need navigation buttons -->
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>

        <!-- If we need scrollbar -->
        <div class="swiper-scrollbar"></div>
    </div>

<script type="text/javascript"> 
//récupération du fichier json grace à url avec valeurs insérer ds var data
var myJson;
$.getJSON( "http://localhost:8080/version_test_appli1_16_swiper/getJSONResult.action",
    function( data ) {
        myJson = data;
    }
);

//alert pour vérifier si on récupère bien le fichier json
var jqxhr = $.getJSON( "version_test_appli1_16_swiper/getJSONResult.action", 
    function( data ) {
    console.log( "success "+data );
    myJson = data['rows'];
    var txt = "";
        for( var key in myJson )
            txt += key+":"+myJson[key];

        alert( txt );

        var nbLigne = myJson.length;
        var maxLigne = 10;
        // on répète la creation du tableau toute les 10 lignes
        for( var iTable = 0; iTable < nbLigne; iTable+=maxLigne ){

            var div = document.createElement('div');
            div.setAttribute("class", "swiper-slide");
            //div.id = "blabla";

            var table = document.createElement("table");
            div.appendChild( table );

            // pour l'entete
            var tr = document.createElement( 'tr' );

            var th = document.createElement('th');
            th.innerHTML = "Objet";
            tr.appendChild( th );

            th = document.createElement('th');
            th.innerHTML = "Date";
            tr.appendChild( th );

            th = document.createElement('th');
            th.innerHTML = "Type séance";
            tr.appendChild( th );

            th = document.createElement('th');
            th.innerHTML = "Numéro";
            tr.appendChild( th );

            table.appendChild( tr );





            // pour le corps
            for( var iLigne=iTable; iLigne < iTable+maxLigne ; iLigne++ ){
                var ligne = myJson[iLigne];
                tr = document.createElement( 'tr' );

                for( var iCell in ligne ){
                    var cell = ligne[iCell];
                    var td = document.createElement('td');
                    td.innerHTML = cell;
                    tr.appendChild( td );

                }

                table.appendChild( tr );

            }

            var divGrid = document.getElementById("slide");
            divGrid.appendChild( div );

        }


    })
    .done(function( data ) {
    console.log( "second success "+data );
    })
    .fail(function( data ) {
    console.log( "error "+data );
    })



//initialisation du swiper quand le document est pret avec Jquery
$(document).ready(function () {
//initialize swiper when document ready  
    var mySwiper = new Swiper ('.swiper-container', {
      // Optional parameters
      direction: 'horizontal',
      loop: true
    })        
 });
</script>

Please tell me if you need any more information in order to help. I’ll be very gratefull for your help. Thanks a lot !!! And sorry again I’m VERY new to git hub and swipper 😉

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
MiloshRollcommented, Mar 21, 2015

Hi ! Ok today I’ve fixed my eyes and I’ve found the problem : swiper spelt with two p…

<div class="swipper-wrapper" id="slide"></div>

instead of :

<div class="swiper-wrapper" id="slide"></div>

Now it is working fine ! Thank you again for your help and for this very cool touch slider !

0reactions
MiloshRollcommented, Mar 20, 2015

What do you mean with live example ? The thing is that i’m developing the app locally on a tomcat server. I don’t how I can give you access to it, Teamviewer ? On the other hand, if you’ve got the whole sources would that help you ? Thank you again for your precious help !

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS: Failed to execute 'getComputedStyle' on 'Window ...
In short: I am trying to understand the meaning of this TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of...
Read more >
Failed to execute 'getComputedStyle' on 'Window' - OutSystems
On my mobile app i am getting an Error on every page which says "Failed to execute 'getComputedStyle' on 'Window': parameter 1 is...
Read more >
Failed to execute 'getComputedStyle' on 'Window': param 1 is ...
Uncaught TypeError : Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. at HTMLBodyElement.
Read more >
parameter 1 is not of type 'Element'. HELP : r/learnjavascript
Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. HELP : r/learnjavascript.
Read more >
T280305 Failed to execute 'getComputedStyle' on 'Window'
Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. Closed, InvalidPublicPRODUCTION ERROR.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found