url
http://localhost/news-events/news.html?file=hosted_service.pdf
Js code
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>
What would the syntax be if i want to add the data of the object = filepath
url
http://localhost/news-events/news.html?file=hosted_service.pdf
Js code
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>
What would the syntax be if i want to add the data of the object = filepath
Share Improve this question asked Mar 6, 2013 at 2:06 inputErrorinputError 6103 gold badges13 silver badges28 bronze badges 1-
$('.divEmbed object').attr('data', filePath);
? – Evan Davis Commented Mar 6, 2013 at 2:09
1 Answer
Reset to default 4You're setting jQuery's data object, when in fact what you want is to change an ordinary attribute. Use this instead:
$('.divEmbed object').attr('data', filePath);