2013-03-06 2 views
0

URLjquery 개체 데이터 값을 동적으로 업데이트 하시겠습니까?

http://localhost/news-events/news.html?file=hosted_service.pdf 

JS 코드

parseURL : function() { 
var _path = window.location.pathname; 
console.log(_path); 
var _locationSearch = location.search; 
var _locationParse = _locationSearch.replace('?file=',''); 
console.log(_locationParse); 
var filePath = "/pdffiles/"+_locationParse ; // /pdffiles/hosted_service.pdf 
$('.divEmbed object').data(filePath); **How to set the data of object? this is wrong** 
console.log(filePath); 
} 

HTML을

<div class="divEmbed"> 
       <object data="" type="application/pdf"> 
        alt : It appears you don't have a PDF plugin for this browser. 
        Click <a href="">here</a> to Download the file. 
       </object> 
      </div> 

내가 개체의 데이터를 추가하려는 경우 구문은 무엇을 것 = 파일 경로

+0

'$ ('. divEmbed 객체 '). attr ('data ', filePath);'? – Mathletics

답변

1

jQuery의 데이터 객체를 설정하고 싶습니다. 실제로 원하는 것은 일반적인 속성을 변경하는 것입니다. 이것을 대신 사용하십시오 :

$('.divEmbed object').attr('data', filePath); 
+0

는 환호했습니다 !!! – inputError

+0

Firefox에서는 작동하지만 크롬에서는 작동하지 않습니까? – inputError

+0

로딩에 신경 쓰지 마라. 천천히 다시 한번. 감사합니다. – inputError

관련 문제