Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2004
    Location
    The First State
    Posts
    233
    Thanks
    9
    Thanked 0 Times in 0 Posts

    help with link method

    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?


    Code:
    <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>

  • #2
    New Coder
    Join Date
    Nov 2006
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •