NOTE: Firefox does not support certain tasks for iframes with style=”display:none”, like adding event listeners. A possible workaround is to add a class that changes the visibility. Here is an example:
var iframe = document.getElementById( 'api-frame' );
var uid = 'af7ce6804d294d5588856a624cb6c8f7
'; var client = null;function loadmodel(){ document.addEventListener('load', () => console.log( 'viewerready' ))
// By default, the latest version of the viewer API will be used. var client = new Sketchfab( iframe );
// Alternatively, you can request a specific version. // var client = new Sketchfab( '1.0.0', iframe );
client.init( uid, { success: function onSuccess( api ){ console.log( 'Success' ); api.load(); api.start();
api.addEventListener( 'viewerready', function() { console.log( 'Viewer is ready' ); // once the viewer is ready, show the iframe let $apiFrame = document.getElementById( 'api-frame' ); $apiFrame.classList.remove( 'hidden' ); // Remove hidden class } ); }, error: function onError( callback ){ console.log( this.error ); } } ); };