...

View Full Version : help with link method



finstah1
12-15-2006, 02:16 PM
I have script that will display Excel data on a page if the browser is IE for Windows. I'm using the link method to show a link to the xls file for non IE Win browsers but I'm not sure how to show an iframe with a link for IE. I'm using the doc.write (which I know the syntax isn't right) but it prints out the entire iframe tag.

Is there something similar to the link method that I can use for an iframe?

Do I need the escape characters in the (Excel format) line?




<script language="javascript" type="text/javascript">
var platform=navigator.platform
var str = new String("Citigroup");
var strXL = new String("Citigroup \(Excel format\)");

if (document.compatMode && document.all && platform=="Win32")
{
str = str.link("teams/analyzer/citigroup.xls")
document.write(str)
document.write("&lt;iframe src='teams/analyzer/citigroup.xls'width='100%' height='500'&gt;&lt;/iframe&gt;");
}
else
{
strXL = strXL.link("teams/analyzer/citigroup.xls")
document.write(strXL)
}
</script>

j9ine
12-16-2006, 04:34 AM
<script>
window.onload = function() {
var os = navigator.platform;
var brows = navigator.appName;
var body = document.getElementsByTagName('body')[0];
var a = document.createElement('a');
a.setAttribute('href','teams/analyzer/citigroup.xls');

if (os=='Win32' && brows.indexOf('Microsoft')!=-1) {
a.innerHTML = 'Citigroup';
var iframe = document.createElement('iframe');
iframe.setAttribute('src','teams/analyzer/citigroup.xls');
iframe.setAttribute('width','100%');
iframe.setAttribute('height','500');
body.appendChild(a);
body.appendChild(iframe);
} else {
a.innerHTML = 'Citigroup (Excel format)';
body.appendChild(a);
}
}
</script>
<body>
</body>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum