Firstly, Marcel Korpel is right: using a server-side technology to include this snippet is the smarter way to go. If that isn't an option for you for whatever reason, you can do this:
To insert it using Javascript, you'd firstly need some way to identify where to put it. You could do this by having a div with a certain ID, or always put it in the same place (e.g.: at the end of the <body>
).
var filename = '../pdf/sign-va.pdf',
w = 720,
h = 540
;
var obj = document.createElement('object');
obj.setAttribute('width', w);
obj.setAttribute('height', h);
var param = document.createElement('param');
param.setAttribute('name', 'Src');
param.setAttribute('value', filename);
obj.appendChild(param);
var embed = document.createElement('embed');
embed.setAttribute('width', w);
embed.setAttribute('height', h);
embed.setAttribute('src', filename);
embed.setAttribute('href', filename);
obj.appendChild(embed);
// here is where you need to know where you're inserting it
// at the end of the body
document.body.appendChild(obj);
// OR, into a particular div
document.getElementById('some_id').appendChild(obj);
If you were using something like jQuery, this becomes much less verbose:
$('<object></object>', { width: w, height: h})
.append($('<param />', { name: 'src', value : filename }))
.append($('<embed></embed>', {
width: w, height: h,
src : filename, href : filename
}))
.appendTo(document.body)
;