Safari displays the javascript source instead of running


i have a web application that has javscript interspersed through the page. What happens is that safari will dump the source of the javascript code instead of executing it. I can reproduce this consistently.

The page is a mashup of different forms of content:

it loads flash videos using osflv and is generated via a php script on the server side. In addition the page also contains calls to Google Map's API to display a map. The content is placed in separate tabs using javascript to provide tab interaction.

I am also using mootools, and not sure if that is potentially causing issues.

Here are the javascript includes:

<script type="text/javascript" src="/js/mootools-1.2.1-core.js"></script>
<script type="text/javascript" src="/js/mootools-1.2-more.js"></script>
<script type="text/javascript" src="/js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="/js/sifr.js"></script>
<script type="text/javascript" src="/js/sifr-debug.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/alerts.js"></script>
<script type="text/javascript" src="/js/swfobject.js"></script>
<script type="text/javascript" src="/js/autocompleter.js"></script>
<script type="text/javascript" src="/js/observer.js"></script>
<script charset='ISO-8859-1' src='/js/rac.js' language='javascript'></script>

rac.js comes from osflv, common.js and alerts.js are custom javascript code that includes custom classes and functions used to either display or manipulate data in the page.

This block of code executes in the page just fine:

<script type="text/javascript">
        var whitney = { src: '/flash/whitney.swf'};
        sIFR.replace(whitney, { selector: 'h6#propertyHeadline', wmode:'transparent',css: {'.sIFR-root': {'color': '#1ca9b9' }}});

This code also executes just fine:

<script language='javascript'>
  var src = '/player';
  if(!DetectFlashVer(9, 0, 0) && DetectFlashVer(8, 0, 0))
   src = 'player8';
  AC_FL_RunContent('codebase', ',0,0,0', 'width', 520, 'height', 440, 'src', src, 'pluginspage', '',    'id', 'flvPlayer', 'allowFullScreen', 'true', 'movie', src, 'FlashVars','movie=media/orig/4b845109d99d0.flv&fgcolor=0x1CA9B9&bgcolor=0x000000&autoload=off&volume=70');

This is the final snippet of code that is embedded in the html towards the bottom of the page before the end of the body tag, Safari will randomly spit out the src code in the browser at any point beyond the good maps script include:

<script src=";v=2&amp;key=googlemapsapikeyblockedout" type="text/javascript"></script>
<script type="application/javascript">

    function InitPropertyDashboardTabs(){
        mytabs = new TabPanel('DashboardTabPanel');
        initializeMap('address blocked out');

    var map = null;
    var geocoder = null;

    function initializeSiteplan()
        var flashvars = {PropertyId:1,BasePath:'/',wmode:'transparent'};
        var params = {wmode: 'transparent'};
        var attributes = {id: 'SWFSitePlan',name: 'SWFSitePlan'};
        swfobject.embedSWF("/flash/FloorplanViewer/FloorplanViewer.swf", "SiteplanFlash", "915", "500", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

    function initializeGallery()
        var  params = {wmode: 'transparent'};..... (more code)

This is what the page with the js dump alt text

this is what the page should look like: alt text

First, you shouldn't use the language attribute, it's deprecated.

The only thing I can see is that you use application/javascript instead of text/javascript in your HTML (there's a difference between what you specify in your HTML and the MIME-type servers use when sending a Javascript file), but I cannot reproduce any errors on Chromium/Linux with a simple test case like

<!DOCTYPE html>
    <script type="application/javascript">
      var i=0;

(Perhaps you can try this, too.)

Just in case: is the script element closed properly? Is all Javascript correct, i.e. does it pass JSLint?

Perhaps you can paste the full source of the HTML page (preferably on something like Pastebin), so we can have a closer look.