html - JQuery only working on Firefox -


i creating html front page users view our 'how to' documents, pdfs fembeded onto page create preview using below jquery. working fine in firefox not work in ie or chrome, appreciated, thanks

    $(document).ready(function() {         "use strict";         $('.btn').click(function() {             var idtosrc = './hta_' + this.id + '.pdf';             $('#viewer').attr('src', idtosrc);         });     }); 

you can using jquery clone() method (the urls used example pdfs):

http://api.jquery.com/clone/

<button type="button" class="btn">change src</button> <div>     <embed id="viewer" src="http://www.education.gov.yk.ca/pdf/pdf-test.pdf" width="500" height="680"></embed> </div>   $(document).ready(function() {         "use strict";         $('.btn').click(function() {             //var idtosrc = './hta_' + this.id + '.pdf';             var idtosrc = "http://www.reservoirminerals.com/files/doc_downloads/test.pdf";             var $viewerdiv = $('#viewer').parent();                       var viewerclone = $('#viewer').clone().attr('src', idtosrc);             $viewerdiv.html(viewerclone);         }); }); 

see working here:

http://jsfiddle.net/w32ra/2/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -